pandas-cookbook icon indicating copy to clipboard operation
pandas-cookbook copied to clipboard

Chapter 4 TypeError:unhashable type:'slice'

Open chenlee1990 opened this issue 3 years ago • 2 comments

when I write this line berri_bikes.loc[:, 'weekday'] = berri_bikes.index.weekday

If we run then we will see the bug: TypeError:unhashable type:'slice'

Anyone can tell me what happen and how to fix the bug?

chenlee1990 avatar Jun 29 '21 14:06 chenlee1990

the problem is sloved

chenlee1990 avatar Jun 30 '21 08:06 chenlee1990

What was the fix? I seem to run into the same problem.

edit: apparently when creating berri_bikes it is essential to use the double brackets: berri_bikes = bikes[['Berri 1']].copy()

jozefkip avatar Oct 04 '21 15:10 jozefkip