I got a dataframe and I want to drop all the rows that contain a value >= 100 in all the columns (in the whole dataframe), not in just one specific column. I tried: df = df[(df < 100).any()] df.drop(df[(df <= 100)].index, inplace=True)
But nothing work... Could you please help?
Once you have the Boolean mask ( df >= 100
or df.ge(100)
) you can select the rows where all values are True
with all(axis=1)
, then reverse the resulting mask with ~
to select the desired rows from the original df.
df = df[~df.ge(100).all(axis=1)]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.