Pandas:多索引列数据框到Excel

2024-09-30 01:34:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建了一个多索引数据框,其列如下所示-

a | | b   | c   | d | d
nan | nan | nan | e | f

现在我必须把它写在excel表格中。 我试过了

df.to_excel(r'C:/Users/Surbhi/Downloads/nir.xlsx',index=False)

它给了我

NotImplementedError: Writing to Excel with MultiIndex columns and no index ('index'=False) is not yet implemented.

然后我试着

df.to_excel(r'C:/Users/Surbhi/Downloads/nir.xlsx',index=True) 并在excel表格中得到如下结构

a   | b   | c   | d | d
e   | e   | e   | e | f

我使用spyder和pandas 1.0.5版

请告诉我该怎么办。蒂亚


Tags: to数据falsedfindexdownloadsnanxlsx

热门问题