这是我的数据框
consumption hour
start_time
2022-09-30 14:00:00+02:00 199.0 14.0
2022-09-30 15:00:00+02:00 173.0 15.0
2022-09-30 16:00:00+02:00 173.0 16.0
2022-09-30 17:00:00+02:00 156.0 17.0
2022-09-30 18:00:00+02:00 142.0 18.0
2022-09-30 19:00:00+02:00 163.0 19.0
2022-09-30 20:00:00+02:00 138.0 20.0
2022-09-30 21:00:00+02:00 183.0 21.0
2022-09-30 22:00:00+02:00 138.0 22.0
2022-09-30 23:00:00+02:00 143.0 23.0
我想这样出去
consumption hour
start_time
2022-09-30 14:00:00+02:00 199.0 14.0
2022-09-30 15:00:00+02:00 173.0 15.0
2022-09-30 16:00:00+02:00 173.0 16.0
2022-09-30 17:00:00+02:00 156.0 17.0
2022-09-30 18:00:00+02:00 142.0 18.0
2022-09-30 19:00:00+02:00 163.0 19.0
2022-09-30 20:00:00+02:00 138.0 20.0
2022-09-30 21:00:00+02:00 183.0 21.0
2022-09-30 22:00:00+02:00 138.0 22.0
2022-09-30 23:00:00+02:00 143.0 23.0
*2022-09-31 00:00:00+02:00 00.0 00.0*
*2022-09-31 01:00:00+02:00 00.0 01.0*
这里我的索引是datetime(start_time),我想创建一个连续的datetime行,值为dummy或zero。
1条答案
按热度按时间2izufjch1#
通过
concat
创建辅助数据框并添加到原始数据框:或者使用
DataFrame.reindex
和新索引,并添加N
小时数: