C 是一个数据系列,形状为 (10000000, ),dtypes 为 dtype(
c.between_time('22:00:00','23:00:00')
这是我得到的错误
TypeError: Index must be DatetimeIndex
我应该如何修复它?
尝试通过初始化空数据框来创建数据框。
我在系列中创建了 3 个虚拟时间的样本
import pandas as pd
C = pd.Series(['22:00:00','22:30:00','23:00:00'])
df = pd.DataFrame()
df['C'] = C
#set index to the obervations after converting them to type datetimeIndex
df.index = pd.to_datetime(C)
print df
print df.between_time(df['C'][0],df['C'][2])
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)