我有下面的數據框,並希望將列第aftr第3列轉置爲行。請幫助。如何將數據幀列轉置爲熊貓中的行
df:
country year perc data1 data2 data3
IN 2015 hjk 75 81 96
US 2015 KTM 100 289 632
Results:
country year perc TransposedColumn Value
IN 2015 hjk data1 75
IN 2015 hjk data2 81
IN 2015 hjk data3 96
US 2015 KTM data1 100
US 2015 KTM data2 289
US 2015 KTM data3 632
這將是很高興看到你目前在你的代碼,你想轉置的實現是。你能補充一點嗎? –
@EastonBornemeier我檢查過的帖子:https://stackoverflow.com/questions/42292986/how-to-transpose-specific-columns-into-rows-in-pandas-associate-other-column-val,但它給錯誤對於我... – Plinus