【发布时间】:2023-04-02 02:55:02
【问题描述】:
我再次尝试在时间条件下挑选出某些行来计算不同时间段的平均值/标准。
file = pd.read_csv('test/Res/1002', sep='\t', encoding = 'utf-8')
print(file['hm']==47)
print(file['hm']==48)
print(1<=file['hm']<=14)
我得到正确评估的 True/False 布尔值列表。但在下面,改为接收这个 -> ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
overn_std = file[(file['hm'] == 47)| (file['hm'] == 48) | (1 <= file['hm'] <= 14) ]
过去我通过将条件or 替换为| 来解决相同的问题。
hm 列的 dtype 是 int。
【问题讨论】:
标签: python pandas dataframe filter conditional-statements