Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
andreareina
on Jan 26, 2022
|
parent
|
context
|
favorite
| on:
A trick to have arbitrary infix operators in Pytho...
Same thing happens in pandas when composing conditionals in a selection operation. You need to use `|` instead of `or`, but its precedence is low so you need to add parens:
df[(df["col1"] == foo) | (df["col2"] == bar)]
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: