原始资料
2019/5/16 00:00 2019/5/16 00:00 0
2019/5/15 23:55 2019/5/16 00:00 0
2019/5/15 23:50 2019/5/16 00:00 0
2019/5/15 23:35 2019/5/15 23:36 0
2019/5/15 23:30 2019/5/15 23:31 0
2019/5/15 23:25 2019/5/15 23:26 0
2019/5/15 23:20 2019/5/15 23:21 0
2019/5/15 23:15 2019/5/15 23:16 0
想要补成
0 2019/5/16 00:00 2019/5/16 00:00 0
1 2019/5/15 23:55 2019/5/16 00:00 0
2 2019/5/15 23:50 2019/5/16 00:00 0
3 2019/5/15 23:45 null 0
4 2019/5/15 23:40 null 0
5 2019/5/15 23:35 2019/5/15 23:36 0
6 2019/5/15 23:30 2019/5/15 23:31 0
7 2019/5/15 23:25 2019/5/15 23:26 0
8 2019/5/15 23:20 2019/5/15 23:21 0
9 2019/5/15 23:15 2019/5/15 23:16 0
我是这样写
df = pd.DataFrame(pd.read_csv('004.csv',header=0))
df
idx = pd.period_range(min(df.DATA_TIME), max(df.DATA_TIME),freq='5T')
df1 =df.reindex(idx, fill_value=0)
df1
但是结果却是
2019-05-15 23:15 0 0 0
2019-05-15 23:20 0 0 0
2019-05-15 23:25 0 0 0
2019-05-15 23:30 0 0 0
2019-05-15 23:35 0 0 0
2019-05-15 23:40 0 0 0
2019-05-15 23:45 0 0 0
2019-05-15 23:50 0 0 0
2019-05-15 23:55 0 0 0
2019-05-16 00:00 0 0 0
请问该怎写比较好~~感谢各位大