I'm trying to export a list of Pandas data frames to Excel files using a generator expression. However nothing is exported once the script has finished executing. It works if I use a for loop, but not using a generator expression. I'm really interested in knowing how it could work, but also why, thanks in advance.
This doesn't work:
def process_pandas_dfs():
(df.to_excel('df_name.xlsx') for df in list_of_dfs)
However this does:
def process_pandas_dfs():
for df in list_of_dfs:
df.to_excel('df_name.xlsx')