Home > Enterprise >  Convert dataframe index values into columns
Convert dataframe index values into columns

Time:04-26

I have a dataframe that looks like this: stats dataframe

What I would love to do, is to turn the PTS and REB value into respective columns with each value underneath, like

PTS   | REB
----------
14.29 | 5.71

Is this possible? I have intermediate experience with pandas, but through googling and the docs, it doesn't appear to be the easiest find.

Thanks!

CodePudding user response:

You could use the transpose functionality.

df_transpose = df.T

or

df_transpose = df.transpose()

Here is the link to the doc:
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.transpose.html

  • Related