Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Renaming index (or is it index?) of pandas data frame fails persistently

This should be easy. I have a pandas data frame with Date as index; it is a period index.

When I plot the data, the legend mentions "Series" while I want it to show "Loan type".

I tried reset_index() and work from there, but ‘Series’ keeps popping up in the upper left corner.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Series  Loans  Loans Housing  ...  Loans Agriculture  Loans_Other
Date                          ...                                
2018Q2  100.0      58.058425  ...          14.498113     2.123517
2018Q3  100.0      58.366364  ...          14.439221     2.097073
2018Q4  100.0      58.588861  ...          14.343509     1.917685
2019Q1  100.0      58.693234  ...          14.189217     1.964198
2019Q2  100.0      58.936376  ...          14.187947     1.848167

Series

>Solution :

Use rename_axis().

df.rename_axis("Loan type", axis=1)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading