【发布时间】:2015-02-04 21:56:20
【问题描述】:
我正在尝试根据两个条件获取 DataFrame 的子集。
这是我的简化示例:
import pandas as pd
test = pd.DataFrame(np.ones(48),
index=pd.date_range('2015-01-01',
periods=48,
freq='1800S'))
我现在想获取时间范围 t > 08:00 和 t
result = test[test.index.hour>8 & test.index.hour<22]
然后我得到ValueError that the truth value of an array with more than one element is ambiguous, use a.any() or a.all() - 我运气不好......
【问题讨论】:
标签: python pandas datetime dataframe