Python Pandas:数据帧转置没有转置 [英] Python Pandas: Dataframe Transpose didn't transpose
本文介绍了Python Pandas:数据帧转置没有转置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据框 df5,我想将列转换为行,反之亦然,
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
谢谢,大厅
推荐答案
您需要为 df5 分配一个新值.
You need to assign a new value to df5.
试试
df5=df5.transpose()
这篇关于Python Pandas:数据帧转置没有转置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文