Home > database >  Conditional filtering of dataframe – TypeError: unsupported operand type(s)
Conditional filtering of dataframe – TypeError: unsupported operand type(s)

Time:06-24

I want to get some data from "Year" columns

that is "22 < x < 100"

and I made this code

df4 = df_y[[df_y["Year"]<100] & [df_y['Year']>22]]

but that doesn't work with this error

"TypeError: unsupported operand type(s) for &: 'list' and 'list'"

what can i do...?

CodePudding user response:

df4 = df_y[(df_y["Year"]<100) & (df_y['Year']>22)]

Use () instead of [] for & operation

  • Related