i used groupby on a dataframe to get desired results. now Groupby result is a Series object and i want to convert into Dataframe. i have used Pd.Dataframe, but only Qty is coming as column output, Other columns from original table are coming as Index or series or tuple.
Original Dataframe
Desired output in Dataframe:
So first I used groupby
to get sum
of Qty
:
StockSummary = StockSummary.groupby(['BussDate','Identifier'])['Qty'].sum()
then I tried below to get BussDate and Identifier as columns in a dataframe along with Qty. but no success. BussDate and Identifier are still coming as index/series/tuple in the dataframe.
StockSummary = pd.DataFrame(StockSummary)
StockSummary.reset_index()
used unstack() but that moves Bussdate values as columns and Identifier as 1 column. not looking for that solution