Submit your inspiring success story or innovative use case to the 2022 Dataiku Frontrunner Awards! ENTER YOUR SUBMISSION

Creating an excel output with multiple sheet

Level 2
Level 2
Creating an excel output with multiple sheet

I am trying to create and excel output with multiple sheet. This is what i've come up with so far.


with output.get_writer("Summary_File"+current_day+".xlsx") as writer:
        report_df.to_excel(writer, sheet_name='summary')
       cleaned_inbound_prepared_distinct_prepared_joined_df.to_excel(writer, sheet_name='Duplicates')
       distinct_biomakers_df.to_excel(writer, sheet_name='Biomakers')
      distinct_subjid_df.to_excel(writer, sheet_name='SubjectIDS')
      distinct_visits_df.to_excel(writer, sheet_name='Vists')
      all_df.to_excel(writer, sheet_name='numeric')
      less_than_df.to_excel(writer, sheet_name='non_numeric')

Operating system used: windows

0 Kudos
1 Reply
Level 3
sheet_names = ['1''2']
# First, save the data as excel format into a bytes string
stream = BytesIO()
excel_writer = pd.ExcelWriter(r"C:\Users\XXXX\Downloads\pythonCode\Multiple_Merged.xlsx"engine='xlsxwriter')
for i, df inenumerate (dataframes):
    df.to_excel(excel_writer, sheet_name=sheet_names[i],index=False)
    workbook  =
    worksheet = excel_writer.sheets[sheet_names[i]]

more formatting

# Rewind to the beginning of the bytes string
0 Kudos