我想將矩陣轉換爲3D數組,或將3D數組轉換爲矩陣。如何輸入數據以及如何在Python中完成轉換工作?如何將矩陣轉換爲3D數組或反之亦然?
我找了很多地方,但沒有答案。請幫我
矩陣:
a b c
d 1 2 3
e 2 3 4
f 4 3 2
數組b:
a d 1
a e 2
a f 4
b d 2
b e 3
b f 3
c d 3
c e 4
c f 2
我可以用堆棧()來實現我的目標是什麼?
喜歡:Python pandas - pd.melt a dataframe with datetime index results in NaN
謝謝你這麼多的具體的答案!但是從pd.melt得到的回報idx全部是NaN,你能檢查它嗎? – yfxia
我可以使用堆棧()來實現我的目標嗎?像http://stackoverflow.com/questions/30984167/python-pandas-pd-melt-a-dataframe-with-datetime-index-results-in-nan – yfxia