【日常水贴 10】pandas 写入 excel 文件避免覆盖已有 sheet
from openpyxl import load_workbook
book = load_workbook(r‘路径 xlsx’)
writer = pd.ExcelWriter(r’路径’, engine=‘openpyxl’)
writer.book = book
writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
df_insert.to_excel(writer, “sheet 名字”,index=False)#sheet 名字不要和 excel 已有的 sheet 重复