I’m trying to write dataframe 0dataframe to a different excel spreadsheet but getting this error, any ideas?
#imports import numpy as np import pandas as pd #client data, data frame excel_1 = pd.read_excel (r'path.xlsx') Odatalocation = (r'path.xlsx') Odataframe = pd.read_excel(Odatalocation, index_col=0, na_values=['NA'], usecols = "A:C") print(Odataframe) #moving client data to new spreadsheet excel_final = pd.read_excel (r'path.xlsx') Odataframe.to_excel(excel_writer=excel_final, sheet_name='Sheet1', na_rep="")
Advertisement
Answer
You need to create and ExcelWriter
object:
writer = pd.ExcelWriter("path.xlsx") dataframe.to_excel(excel_writer=writer, sheet_name='Sheet1', na_rep="") writer.save()