import pandas as pd
import numpy as np
idx2=[pd.to_datetime('2016-08-31 22:08:12.000'),
pd.to_datetime('2016-08-31 22:08:12.200'),
pd.to_datetime('2016-08-31 22:08:12.400')]
test=pd.DataFrame({'value':[1,1,3], 'groups' : ['A',np.NaN,'A']},index=idx2)
test
Out[27]:
groups value
2016-08-31 22:08:12.000 A 1
2016-08-31 22:08:12.200 NaN 1
2016-08-31 22:08:12.400 A 3
我需要22:08:12.200
和22:08:12.400
之間只保留數據,所以我很自然地使用between_time
:
test.between_time('22:08:12.200','22:08:12.400')
給
ValueError: Cannot convert arg ['22:08:12.200'] to a time
這裏有什麼問題?如何根據時間以毫秒信息切片我的dataframe
?
這麼好。謝謝 !!! –