0

df.groupby(['col1','col2']).count() My groupby returns a dataframe (shape = 5, 1) like this

col1 col2 count
1      1    10
       2     5
       3     2
2      1     4
       2     5

I would like to covert this into (5, 3) dataframe with col1 col2 being real columns.

col1 col2 count
1      1    10
1      2     5
1      3     2
2      1     4
2      2     5

I found several questions on this forum and outside. No luck.

Sociopath
  • 13,068
  • 19
  • 47
  • 75
hereNnow
  • 41
  • 4
  • 1
    Use `.reset_index()`. – shaik moeed Mar 16 '20 at 05:11
  • 1
    Just FYI for new programmers. I had done reset_index didn't get results, hence asked this question. But after reading through the comments from other question, I realized, I need to add inplace=True – hereNnow Mar 16 '20 at 05:22

0 Answers0