我正在尝试重新采样时间序列。我似乎无法让它工作。基于其他示例,我不明白为什么这不返回时间序列:
df1 = pd.DataFrame({'Time': ['2019-08-02 09:50:10.100','2019-08-02 09:50:10.200','2019-08-02 09:50:10.400''2019-08-02 09:50:10.100','2019-08-02 09:50:10.200','2019-08-02 09:50:10.400'],
'Object': ['A','A','A','B','B','B'],
})
df1['Time'] = pd.to_datetime(df1['Time'])
df1 = df1.set_index(['Time']).resample('100ms')
print(df1)
出去:
DatetimeIndexResampler [freq=<100 * Millis>, axis=0, closed=left, label=left, convention=start, base=0]
预期输出:
Time Object
0 2019-08-02 09:50:10.100 A
1 2019-08-02 09:50:10.200 A
2 2019-08-02 09:50:10.300 Nan
3 2019-08-02 09:50:10.400 A
4 2019-08-02 09:50:10.100 B
5 2019-08-02 09:50:10.200 B
6 2019-08-02 09:50:10.300 Nan
7 2019-08-02 09:50:10.400 B