Skip to content
Advertisement

Pandas Add rows for each column

I apologise for the title, I know it isn’t the most helpful. What I’m attempting to do is restructure my data so that each of a given column is given it’s own row with certain values carried over from the previous dataframe.

My Data in its current form is something like this:

JavaScript

And I want to restructure it so I get a result like this:

JavaScript

How would I do this?

I know I could go through each row, grab the relevant data and concat a dataframe but I was hoping for a much better alternative

Advertisement

Answer

Given:

JavaScript

Doing:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement