-1

I have a table in csv that looks like this: enter image description here

I want to tranpose it to look like this, where the columns are nmow rows of a new column called ACCOUNTLABEL, and the values are in a corresponding column called VALUE: enter image description here

Any help? thanks!

Andrew Lim
  • 33
  • 1
  • 5

2 Answers2

1

Edit: I just noticed that your question has nothing to do with transposing a DataFrame, but I will leave this here, in case it helps.

Use df.T for this. It uses the linked method.

I didn't downvote your question, but someone did because the provided link is the first search result if you google 'transpose pandas dataframe'.

1

You might want to look at pandas.melt function : https://pandas.pydata.org/docs/reference/api/pandas.melt.html

I wouldn't call that a 'transposition' but 'un-pivoting' a table.

maggle
  • 485
  • 4
  • 11