import pandas as pd import matplotlib.pyplot as plt from icecream import ic bikes = pd.read_csv(r'C:\Users\chenl\Desktop\pandas_test\data\bikes.csv', sep=';', encoding='latin1', parse_dates=['Date'], dayfirst=True, index_col='Date') berri_bikes = bikes['Berri 1'].copy() berri_bikes.loc[:, 'weekday'] = berri_bikes.index.weekday weekday_counts = berri_bikes.groupby('weekday').aggregate(sum) ic(weekday_counts)
第8行代码在运行时,出现了TypeError: unhashable type: 'slice',不知如何解决?感觉应该是赋值方式出了问题。