【发布时间】:2020-07-29 17:09:04
【问题描述】:
我正在查看文档中的this example:
df.loc[lambda df: df['shield']==8]
如何用 OR 条件扩展它?我正在尝试这样做,但它不起作用:
df.loc[lambda df: df['shield']==8 or df['max_speed'] ==1]
另外,作为旁注,在这种情况下 lambda 函数的意义是什么,因为:
df.loc[df['shield']==8]
工作得很好。
【问题讨论】:
-
绝对不要使用函数来索引,它们在这里毫无意义。此外,您应该使用bitwise operators 链接条件。更多详情请查看this answer
标签: python pandas lambda pandas-loc