I've got an SQLite query I want to run multiple times to create multiple Pandas data frames based on the year of interest. Something like this (but this definitely doesn't work). Basically I'm trying to loop the data frame creation over the year
list to create the 4 data frames (1 for each year) and I'm now stuck at how to do this even after quite a bit of Googling.
year = [2018, 2019, 2020, 2021]
query = '''
SELECT
some stuff
FROM table
WHERE table.YEAR = ?
'''
for x in year:
df[x] = pd.read_sql_query(query, db, params=[x])