[英]create pandas.DataFrame from Postgreql and convert multiple rows and one column to one row and multiple column
我有一个看起来像这样的 postgresql 数据库:
price
1
2
4
9
7
8
3
7
5
3
7
我希望它看起来像这样:1 2 4 9 7 8 3 7 5 3 7
I'm reding it using pandas.read_sql()
now I want to convert that the DataFrame will be instead of 11 rows and one column to be 1 row and 11 column, from what I'm understanding I need to use the pandas.melt()
function 但我不明白怎么做?
你可以做
df.T
Out[7]:
0 1 2 3 4 5 6 7 8 9 10
price 1 2 4 9 7 8 3 7 5 3 7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.