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

Reordering Index to a specific order

I have a dataframe called exam and I would like to sort the month column (which is the index) according to the common order (Jan, feb, mar, apr, etc). However, it seems to be sorted in ascending order. I tried the reindex command but it didn’t make a difference. How can I order it as I want?

Here is the code

exam.reindex(['January','February','March','April','May','June','July','August','September','October','November'])

Here is the dataframe
enter image description here

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

>Solution :

You need to assign it back

exam = exam.reindex(['January','February','March','April','May','June','July','August','September','October','November'])
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