我的时间序列数据如下:
print(df)
ric datel timel val
0 xyz 2017-01-01 09:00:00 2
1 xyz 2017-01-01 09:04:00 5
2 xyz 2017-01-01 09:37:00 6
现在我必须将丢失的时间戳填充到09:45:00
预期产出:
ric datel timel val
0 xyz 2017-01-01 09:00:00 2
1 xyz 2017-01-01 09:01:00 nan
2 xyz 2017-01-01 09:02:00 nan
3 xyz 2017-01-01 09:03:00 nan
4 xyz 2017-01-01 09:04:00 5
...
...
37 xyz 2017-01-01 09:37:00 6
...
...
45 xyz 2017-01-01 09:45:00 nan
我所尝试的:
df1=df.resample("1 min", on ='datel').first()
其输出为:
ric datel timel val
datel
2017-01-01 xyz 2017-01-01 09:00:00 2
还尝试了pd.date_range
,但它主要适用于datetime列。
我有两个不同的栏目日期和时间。有没有一种方法可以在不将日期和列合并到datetime的情况下实现这一点
生成日期范围为date_的日期后,您可以使用类似于以下函数的函数将其拆分
返回值可以输入df
从日期时间导入日期时间
主要思想是由^{} 创建的} :
time
使用^{与
resample
类似的解决方案:相关问题 更多 >
编程相关推荐