I have a dataframe:
grouped_df = df.groupby("DATE").sum()
The dataframe looks like:
The group by column DATE
is shown as index here. I want the column DATE
to be a separate column rather than index.
The condition is that grouped_df['DATE']
should display the data instead of an error.
CodePudding user response:
You can use
grouped_df = df.groupby("DATE", as_index=False).sum()
# or
grouped_df = df.groupby("DATE").sum().reset_index()