sheet1=[FC_filter1,FC_filter2,FC_filter3]
with pd.ExcelWriter(path, mode='a', if_sheet_exists='replace', engine="openpyxl") as writer:
FC_filter1.to_excel(writer, sheet_name='FC_filter1',index='False')
FC_filter2.to_excel(writer, sheet_name='FC_filter2',index='False')
FC_filter3.to_excel(writer, sheet_name='FC_filter3',index='False')
Can we make this code into one line using for loop instead of mentioning FC_filter1,2,3 each time ?
for sheet_filter in sheet1: with pd.ExcelWriter.... The only problem is that you don't have an array of sheet titles. There is no clean way in python to convert variable identifier to string. Instead, put the strings into another array. ["FC_filter1","FC_filter2","FC_filter3"].