Dataframe use groupby precautions

Dataframe use groupby precautions

In the case of knowing that there are many rows of data for each date, if we combine a certain column of data according to the date
insert image description here

Then use the groupby function

But when the dataframe is used directly, an error is reported. In desperation, the dataframe can only be saved locally, and then read again. After using this function, save it at last

df_1_weekday_morning.to_csv('路段1早高峰.csv',encoding = 'utf_8_sig')
df_1_weekday_morning_new = pd.read_csv('路段1早高峰.csv')
df_1_weekday_morning_new = df_1_weekday_morning_new.groupby('date').sum()
df_1_weekday_morning_new.to_csv('路段1早高峰.csv',encoding = 'utf_8_sig')

Well, finally achieved such a result

Well, finally achieved such a result
insert image description here

Guess you like

Origin blog.csdn.net/weixin_43697614/article/details/122968359