简体   繁体   中英

Python Pandas: Dataframe Transpose didn't transpose

I have a dataframe df5 which I want to transpose the columns into rows and vice-versa,

DayofWeek   Avg_Shopping_Trips  Avg_Profit
0   5.Saturday  1096.750000 185040.397500
1   6.Sunday    1489.666667 178546.993333

I tried the following code but it didn't work. What am I doing wrong here? Please help.

df5.transpose()
df5

Thanks, Lobbie

You need to assign a new value to df5.

Try

df5=df5.transpose()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM