I would like to write a function that saves multiple data frames into csv files at once with the file names corresponding to the data frame name. For instance if I have my_data_frame_1= county1_zipcodes I would like to write a function that takes my_data_frame_1 and saves it as my_data_frame_1.csv. So far I have tried the following:
def get_df_name(df):
    name =[x for x in globals() if globals()[x] is df][0]
    return name
def save_df_csv(*args):
    '''
    To save all the data frames into csv files
    '''
    for df in args:
        print (df)
        df_name = get_df_name(df)
        df.to_csv(df_name+'.csv',index=False)
    return
However, this doesn't work. The functions are imported from another script and globals() gives an empty list. I have tried using locals() but that doesn't work either (it gives me df as the data frame name). Any help is appreciated.
