[英]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.