python pandas to_excel为什么会自动删除其他sheet

df = pandas.read_excel('test.xlsx')
df = pandas.pivot_table(df, index=['a'], columns=['b'], aggfunc=numpy.sum)
excelWriter=pandas.ExcelWriter('test_new.xlsx')--test_new.xlsx是一个已经存在的excel文件,有两个sheet1、sheet2
df.to_excel(excelWriter, sheet_name='Sheet1')
excelWriter.save()
执行完之后,之前test_new.xlsx里的Sheet2为什么没有了,怎么才能保留

我搜索了一波,无法实现
https://github.com/pandas-dev/pandas/issues/3441
之前有人在github上面建议,希望增加一个选项,但是被开发者认为不可实现,所以关闭了issue

你可以使用

openpyxl 引擎试试。
https://stackoverflow.com/a/20221655/4795055

写的时候看有没有参数指定sheet

不然试试pyexcel?

pyexcel是支持的 https://www.cnblogs.com/yuwensong/p/3771787.html

推荐使用xlrd模块