Drop rows depending of different criterias where there are also nulls and NA's

Viewed 23

I have a df that contains multiple columns but I want to filter for an automation.

Columns are called (X and Y) but I want to select the by position in the dataset not the name of the column.Those columns have values from 0 to 100 and NA's. ( I cannot delete row's with NA's because it has important information) I want to make a filter to drop the columns where:

X >= 96.5 and Y >96 for example.

The problem is that I've got the same error all the time:

TypeError: '>' not supported between instances of 'tuple' and 'float'

I've been looking in StackOverflow but can't find the solution.

I tried

df.drop(df[(df.columns[9] > 96.5) & (df.columns[12] > 96.5)].index)

In that case df.columns[9] is X and df.columns[12] is Y.

Any suggestions/ideas?? Thank you in advance!

0 Answers
Related