Tikhon
Tikhon

Reputation: 451

Python DataFrame ExcelWriter, returns an error

I am trying to over-write specific tabs in an excel file (leaving the rest intact). I am trying to copy synatx from the documentation but I get an error.

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

This returns the error:

NameError: name 'ExcelWriter' is not defined

Hoping for some advice, I am very much a beginner at coding.

Thanks in advance.

Upvotes: 1

Views: 5862

Answers (1)

Jaydeep Devda
Jaydeep Devda

Reputation: 735

your script is not recognize 'ExcelWriter' keyword. it is part of python's pandas library. you should write below things to work it out.

please try :

import pandas as pd and use

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

or import pandas.ExcelWriter as ExcelWriter

Upvotes: 4

Related Questions