0

I understand that groupby type with sum as the agg function does the following:

Before:

type    stale   price      
orange    yes     1    
apple     yes     2     
orange    no      3   

After:

type    stale   price      
orange    yes     1    
          no      3     
apple     no      2   

Is there an argument in groupby that would allow me to display all cell values? Therefore placing a value of "orange" above where it says apple instead of forcing the reader to understand that the second row still belongs to orange? It may seem useless for this example, but in a larger dataset, it is helpful to be able to see all the cell values.

pault
  • 41,343
  • 15
  • 107
  • 149
machinelearner07
  • 113
  • 1
  • 1
  • 12
  • 1
    `as_index = False`? – pault Jul 16 '19 at 21:05
  • Yes! That worked. Thank you – machinelearner07 Jul 16 '19 at 21:11
  • Possible duplicate of [pandas groupby without turning grouped by column into index](https://stackoverflow.com/questions/32059397/pandas-groupby-without-turning-grouped-by-column-into-index) or [What is as_index in groupby in pandas?](https://stackoverflow.com/questions/41236370/what-is-as-index-in-groupby-in-pandas) – pault Jul 16 '19 at 21:12

1 Answers1

0

Try resetting the index:

grouped_dat.reset_index()

Sam
  • 541
  • 1
  • 3
  • 10