I am creating multiple dataframes with a function I have written and I want to be able to assign the name of the dataframe as an argument in the function.
def execute_query(query, df):
conn.cursor().execute(query)
df = pd.read_sql(query, conn)
return df
q1 = """
select foo
from bar
"""
execute_query(q1, 'market_share_df')
I have written the function above and when I call it, it returns a dataframe with the proper data. However, it doesn't seem like the variable name as been assigned "market_share_df". Unsure of how to do this, any ideas are welcome. Thanks