I am using answer provided in below SO link to append data in xlsx file.
https://stackoverflow.com/a/38075046/1896796
I am calling the helper method like below,
append_df_to_excel('test2.xlsx', df_repo, index= False, header = False)
I have already added the column names in my excel sheet. But all my dataframe does not have same columns count or order. Though what ever columns are there in the dataframe will have the same column name as in the excel.
How can I add the dataframe columns to my excel under the matching column name?
my df1,
durable_medical_equipment pcp specialist diagnostic imaging generic formulary_brand non_preferred_generic emergency_room inpatient_facility medical_deductible_single medical_deductible_family maximum_out_of_pocket_limit_single maximum_out_of_pocket_limit_family plan_name pdf_name
0 False False False False False False False False False False False False False False ABCBCBC adjnajdn.pdf
df2,
pcp specialist generic formulary_brand emergency_room urgent_care inpatient_facility durable_medical_equipment medical_deductible_single medical_deductible_family maximum_out_of_pocket_limit_single maximum_out_of_pocket_limit_family plan_name pdf_name
0 True True False False True True True True True True True True ABCBCBC adjnajdn.pdf
In my excel , the order is like below-
durable_medical_equipment pcp specialist diagnostic imaging generic formulary_brand non_preferred_generic emergency_room inpatient_facility medical_deductible_single medical_deductible_family maximum_out_of_pocket_limit_single maximum_out_of_pocket_limit_family plan_name pdf_name