I have refined an existing xlsx
file and want to create three new files based on the content. Successful in getting three new outputs, but not able to write it to new xlsx
files.
I tried installing excelwriter
but that didn't fixed my problem.
import pandas as pd
import xlsxwriter
xl_file = pd.ExcelFile('C:\\Users\\python_codes\\myfile.xlsx')
dfs = pd.read_excel('myfile.xlsx', sheetname="Sheet1")
test = dfs.drop_duplicates(subset='DetectionId', keep='first', inplace=False)
dfs2 = test[test['list_set_id'] == 1]
print(dfs2)
writer = dfs2.ExcelWriter('newfile.xlxs', engine='xlsxwriter')
df.to_excel(writer, sheet_name='Sheet1')
writer.save()
I want to write new xlsx
file with the filtered content from the existing file.
ExcelWriter
belongs to the pandas
module, not to a DataFrame
instance.
writer = dfs2.ExcelWriter
should be writer = pd.ExcelWriter