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

I want to pivot down the data from column level to row level in pandas

I have data in the below format

Head Sub Head Sub Sub Heads 20210401 20210501 20210601 20210701
Sales Accounts Indirect Tax GST Return Filing 11000 7000 8500 3500

Source Format

However, I want to transform it to the below format using Python

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

Target Format

>Solution :

Use from melt method in pandas

Read the below doc:

https://pandas.pydata.org/docs/reference/api/pandas.melt.html

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