0

Please see images -

enter image description here enter image description here

After creating a dataframe, I use groupby, then I reset the index column only to find that the column for 'county' is still unseen by the dataframe. Please help to rectify.

Akshay Sehgal
  • 18,741
  • 3
  • 21
  • 51

1 Answers1

0

The df.reset_index() by default is not an "inplace" operation. But with use of the inplace parameter you can make it behave as such.

1. Either use inplace=True -

mydf.reset_index(inplace=True)

2. Or save the df into another (or the same) variable -

mydf = mydf.reset_index()

This should fix your issue.

Akshay Sehgal
  • 18,741
  • 3
  • 21
  • 51