我已經在格式數據幀列轉
Open,0.001
High,0.001
Low,0.001
Close,0.001
Volume,0
Adj Close,0.001
SMA_20,0.0010000000000000005
SMA_50,0.0010000000000000007
date_of_trade,2016-02-05 00:00:00
code,AFT
Open,2.9300000000000002
High,2.9700000000000002
Low,2.8300000000000001
Close,2.8999999999999999
Volume,631100
Adj Close,2.8999999999999999
SMA_20,3.2214999999999998
SMA_50,3.0767999999999969
date_of_trade,2016-02-05 00:00:00
code,1PG
Open,6.9900000000000002
High,7.0999999999999996
Low,6.9000000000000004
Close,6.9000000000000004
Volume,4300
我想轉換成以下格式
open,high,low,close,volume,adj_close,sma_20,sma_50,data_of_trade,code
.001,.001,.001,0,.001,.0001000005,.0000100007,2016-02-05 00:00:00,aft
2.93,2.97,.......................................................,1pg
在源文件中的第一列是列名和源文件數據二是相應的列值。
我試過樞軸等,但無法使它工作。任何幫助是值得歡迎的。
我無法理解你想要的輸出。你是否想要首先列出所有列名,然後是所有列值(按列名排序)? –
是的,你是正確的。我想把列名放在第一行,後面跟着每行的數據值。請參閱我提到的格式q – NewtoPython
第1行:開放,高,低等。第2行:0.01等。像這樣? row2的順序依賴於row1的順序嗎?另外,有什麼問題,你想要代碼做這個或什麼? –