The following for
loop was intended to create a dataframe
made up of appended tables using the elements in col_list
(of which there are currently 4 elements). However, it does not work and only produces contents from one table rather than the four.
col_list = df['ref_name'].tolist()
df_all = None
conn = sqlite3.connect('all_data.db')
for col in col_list:
query = "SELECT * FROM " + col + ";"
df = pd.read_sql_query(query, conn)
if df_all is not None:
df_all.append(df)
else:
df_all = df
conn.close()
df_all = df_all.sort_values(by = 'date')
df_all = df_all.reset_index(drop=True)