create pandas dataframe from groupby code example
Example 1: pandas new df from groupby
df = pd.DataFrame(old_df.groupby(['groupby_attribute'])['mean_attribute'].mean())
df = df.reset_index()
df
Example 2: pandas groupby
data.groupby('month', as_index=False).agg({"duration": "sum"})