how to fix groupby elimination of index?
Question:
Answers:
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.
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.