我尝试多次运行此程序,但现有的excel文件未更新。有人可以指导我完成正确的过程吗?感谢您的帮助!
import pandas as pd
import openpyxl as pl
manifest_df = pd.read_excel(r'C:\Users\dhruvjadhav\PycharmProjects\Alpha\PassengerManifest.xlsx')
manifest_df['Current Balance'] = manifest_df['Balance'] - manifest_df['Fare']
print(manifest_df)
filename = (r'C:\Users\dhruvjadhav\PycharmProjects\Alpha\PassengerManifest.xlsx')
wb = pl.load_workbook(filename)
ws = wb.worksheets[0]
for ws in wb.worksheets:
print(ws.title)
with pd.ExcelWriter("PassengerManifest.xlsx", engine="openpyxl", mode="a") as writer:
manifest_df.to_excel(writer, sheet_name="ws.title")
writer.save()
狐的传说
相关分类