Skip to content
Advertisement

Getting error in dataframe typeError: ‘Series’ objects are mutable, thus they cannot be hashed

I am trying to apply this operation on my dataframe df:

df[df.a, 'b'] = df.c*df.b

where data types of a,b,c are:

a: bool
b: float64
c: float64

But I am getting the error TypeError: 'Series' objects are mutable, thus they cannot be hashed

Is it happening because of na value present in column b or c? If yes, is there a way to ignore the operation for na values?

Thanks.

Advertisement

Answer

Please try use the loc accessor and it should be fine.

df.loc[df.a,'b']=df.c*df.b
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement