I want to delete rows when a few conditions are met:
For instance, a random DataFrame is generated:
import pandas as pd import numpy as np df = pd.Da
For reasons that aren't 100% clear to me, pandas plays nice with the bitwise logical operators | and &, but not the boolean ones or and and.
pandas
|
&
or
and
Try this instead:
df = df[(df.one > 0) | (df.two > 0) | (df.three > 0) & (df.four < 1)]