【发布时间】:2021-11-04 15:47:15
【问题描述】:
看看是否有人知道如何在 pandas 中链接多个条件......我正在寻找这样的形式:
df[(df.col1>2)&df.col2<5) or (df.col5==5)&(df.col3>=78)]
到目前为止,我还没有找到允许我在示例中包含 or 条件的解决方案。
感谢任何帮助 1
【问题讨论】:
-
|有什么问题?df[((df.col1 > 2) & (df.col2 < 5)) | ((df.col5 == 5) & (df.col3 >= 78))]Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()中提供的示例几乎相同
标签: python pandas dataframe conditional-statements filtering