[英]How to export a dictionary to excel using Pandas
根據您向我們展示的內容(不可復制),您需要pandas.MultiIndex
df_ = df.set_index(0) # `0` since your tuples seem to be located at the first column
df_.index = pd.MultiIndex.from_tuples(df_.index) # We convert your simple index into NDimensional index
# `~.unstack` does the job of locating your periods as columns
df_.unstack(level=-1).droplevel(0, axis=1).to_excel(
"file location", index=True
)
您可以嘗試導出到 csv
df.to_csv(r'Path where you want to store the exported CSV file\File Name.csv', index = False)
然后可以輕松地將其轉換為 excel 文件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.