Python DataFrame ExcelWriter,returns 一个错误

Python DataFrame ExcelWriter, returns an error

我正在尝试覆盖 excel 文件中的特定选项卡(保持其余部分不变)。我正在尝试从文档中复制 synatx,但出现错误。

with ExcelWriter('C:\Users\Tiki\Desktop\work\VFT Technicals\Production2\dashboard_v2.xlsx') as writer: 
    output_rsi.to_excel(writer,sheet_name='rsi')

这个returns错误:

NameError: name 'ExcelWriter' is not defined

希望得到一些建议,我是编码的初学者。

提前致谢。

您的脚本无法识别 'ExcelWriter' 关键字。 它是 python 的 pandas 库的一部分。 你应该写下面的东西来解决它。

请尝试:

import pandas as pd 并使用

with pd.ExcelWriter('C:\Users\Tiki\Desktop\work\VFT Technicals\Production2\dashboard_v2.xlsx') as writer: 
    output_rsi.to_excel(writer,sheet_name='rsi')

import pandas.ExcelWriter as ExcelWriter