我需要在15分钟的时间间隔基础上拆分我的数据日历时间
例如,数据如下所示
ID | rh_start_time | rh_end_time | total_duration
5421833835 | 31-12-2023 13:26:53 | 31-12-2023 13:27:03 | 10
5421833961 | 31-12-2023 13:23:50 | 31-12-2023 13:39:10 | 360
字符串
我想把它分成15分钟的间隔,如下所示
ID | rh_start_time | rh_end_time | total_duration | Interval Start
5421833835 | 31-12-2023 13:26:53 | 31-12-2023 13:27:03 | 10 | 31-12-2023 13:00:00
5421833961 | 31-12-2023 13:23:50 | 31-12-2023 13:39:10 | 360 | 31-12-2023 13:00:00
5421833961 | 31-12-2023 13:23:50 | 31-12-2023 13:39:10 | 360 | 31-12-2023 13:30:00
型
我尝试使用explode + seq,但它以15分钟的块创建数据(例如2023-12-31 13:26:53,2023 -12-31 13:41:53),但不是在实际的日历中
intervals.withColumn(
"rh_interval_start_ts",
explode(expr("sequence(rh_start_time, rh_end_time, interval 30 minutes)")),
)
型
1条答案
按热度按时间6xfqseft1#
一个解决方案是准备间隔并进行连接:
字符串
或者,您可以在开始时间的楼层上进行分解:
型