Skip to content

Tag: pandas

Pandas: Pivot a DataFrame, columns to rows

I have a DataFrame defined like this: The DataFrame is now this: I want to pivot the DataFrame so that it then looks like this: I think I want to do this via pivoting, but I’ve not yet worked out how to do this using the pivot() or pivot_table()functions. How can I do this, with or without using a pivot…