【发布时间】:2021-12-02 11:04:42
【问题描述】:
我正在寻找一种优雅的解决方案来创建具有混合时间戳的多个数据帧
我有一个 dataframe 有超过 16 列的数千行,其中一列的时间戳值如下:
2021-09-28 00:00:00 ~ 2021-09-28 23:59:59
另外,时间戳值在数据帧上没有连续使用,并且混淆了时间戳。
示例
IN [1] : df["datetime"][24082:24085]
OUT [1] :
24082 2021-09-28 07:25:21.446
24083 2021-09-28 07:25:22.444
24084 2021-10-01 19:49:40.549
24085 2021-10-01 19:49:41.549
我要做的是从数据帧创建多个数据帧,这取决于时间戳的日期,例如;
df1 is the rows with 2021-09-28 00:00:00.001 ~ 23:59:59.999
df2 is the rows with 2021-09-29 00:00:00.001 ~ 23:59:59.999
df3 is the rows with 2021-09-30 00:00:00.001 ~ 23:59:59.999
...
dfn is the rows with latest date
如何实现上述数据框?
【问题讨论】:
标签: python pandas dataframe datetime group-by