1

How can I convert columns to rows in a pd.dataframe, currently my code is as below in, instead of having my values returned in columns I want them to be displayed in rows, I have tried using iterrows:

            df = pd.DataFrame (columns = cleaned_array)
            output = df.to_csv ( index=False, mode='a', encoding = "utf-8")
            print(output)
user3738022
  • 37
  • 2
  • 4
  • 11

2 Answers2

0

You want to use the tranpose function.

df.T or df.transpose()

Gus Beringer
  • 172
  • 9
0

Try this:

df = pd.DataFrame (columns = cleaned_array)

df.T

This will interchange your rows and columns