0

I stacked a dataframe using:

df.groupby(["date", "level", "key", "isUsed"]).agg({'NetSalesExVATGBP':'sum'}).unstack(fill_value=0).stack()

To get the resulting dataframe:

enter image description here

How to transform this dataframe to get all rows with all values?

date level key isUsed NetSalesExVatGBP
2020-08-07 1 1 0 9882.42
2020-08-07 1 1 1 174.79
2020-08-07 1 2 0 6742.23

and etc...

I know that it is possible to access individual elements with iterrows() method and then save it to separate lists and create dataframe from that, but it seems very bad method to do it.

MichiganMagician
  • 273
  • 2
  • 15

0 Answers0