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

split column values into separate rows (pivot)

I have a dataset that looks like this:

App    Downloads    Permissions
A      123          56
B      89           12

I want to modify the dfto look like like this:

App    Title              Value    
A      Downloads          123
A      Permissions        56
B      Downloads          89
B      Permissions        12

How can I achieve this? I have looked into the pivot_table functions but it seems a bit different than what I am trying to achieve. Also, not sure how to add the names (Title/Value) for the new columns I want to create

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 could use melt to get these results

df.melt(value_vars = ['Downloads', 'Permissions'])
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