سؤال

I have a dataframe df in pandas that was built using pandas.read_table from a csv file. The dataframe has several columns and it is indexed by one of the columns (which is unique, in that each row has a unique value for that column used for indexing.)

How can I select rows of my dataframe based on a "complex" filter applied to multiple columns? I can easily select out the slice of the dataframe where column colA is greater than 10 for example:

df_greater_than10 = df[df["colA"] > 10]

But what if I wanted a filter like: select the slice of df where any of the columns are greater than 10?

Or where the value for colA is greater than 10 but the value for colB is less than 5?

How are these implemented in pandas? Thanks.

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top