如何克服 'DataFrame' object has no attribute 'excelwriter' in pandas for Python
How to overcome 'DataFrame' object has no attribute 'excelwriter' in pandas for Python
我已经优化了现有的 xlsx
文件,并希望根据内容创建三个新文件。成功获得三个新输出,但无法将其写入新的 xlsx
文件。
我尝试安装 excelwriter
但这并没有解决我的问题。
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()
我想用现有文件中的过滤内容编写新的 xlsx
文件。
ExcelWriter
属于 pandas
模块,不属于 DataFrame
实例。
writer = dfs2.ExcelWriter
应该是 writer = pd.ExcelWriter
我已经优化了现有的 xlsx
文件,并希望根据内容创建三个新文件。成功获得三个新输出,但无法将其写入新的 xlsx
文件。
我尝试安装 excelwriter
但这并没有解决我的问题。
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()
我想用现有文件中的过滤内容编写新的 xlsx
文件。
ExcelWriter
属于 pandas
模块,不属于 DataFrame
实例。
writer = dfs2.ExcelWriter
应该是 writer = pd.ExcelWriter