Skip to content Skip to sidebar Skip to footer

Pandas Function Return Multiple Values Error - Typeerror: Unhashable Type: 'list'

I have written a pandas function and it runs fine (the second last line of my code). When i try to assign my function's output to columns in dataframes i get an error TypeError: un

Solution 1:

Change:

df[['bd_first'],['bd_second'],['ad_first'],['ad_second']] = ...

to

df[['bd_first', 'bd_second', 'ad_first', 'ad_second']] = ...

This will fix your type-error, since index elements must be hashable. The way you tried to index into the Dataframe by passing a tuple of single-element lists will interpret each of those single element lists as indices

Post a Comment for "Pandas Function Return Multiple Values Error - Typeerror: Unhashable Type: 'list'"