Home > Software design >  Pandas: Unhashable type list
Pandas: Unhashable type list

Time:11-15

I'm using this code to drop values with condition df['CNT_CHILDREN'] =df.drop([df['CNT_CHILDREN'] > 10].index)

As an error i have this result

TypeError: unhashable type: 'list'

CodePudding user response:

Try:

df = df.drop(df[df['CNT_CHILDREN'] > 10].index)
#            ^--- you forgot df            

df.drop method drop specified labels from rows so you have to pass the index and not the rows themselves.

>>> df[df['CNT_CHILDREN'] > 10].index
Int64Index([3, 5, 8, 13], dtype='int64')  # dummy data
  • Related