我制作了一個隨機表,我想將其轉移到資料透視表,使用定義函式和 for 回圈。我想讓代碼可重用和自動。

uj5u.com熱心網友回復:
在 pandas 中讀取檔案。請參閱有關read_excel和read_csv的檔案
然后,
df = pd.set_index(['Date', 'State', 'Name').unstack()
df
然后您可以寫入df另一個 excel 或 csv 檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/408640.html
標籤:
