Instead of doing:
a=pd.DataFrame()
d=pd.DataFrame()
c=pd.DataFrame()
d=pd.DataFrame()
e=pd.DataFrame()
each at a time. Is there a quick way to initialize all variables with empty dataframe? Because eventually I want to use for loop to assign dataframe values to
var_names=[a,b,c,d,e]
Basically, I need to assign values from a much bigger dataframe to lots of small dataframe with targeted names(possible complicated names, just for easy understanding)
variables=[ag_2018,al_2018,au_2018,bu_2018,cu_2018,fu_2018,hc_2018,
ni_2018,pb_2018,rb_2018,ru_2018,sn_2018,sp_2018,wr_2018,
zn_2018]
for var in variables:
var=(a portion of a much bigger dataframe)
These are my codes. Python won't allow me to do it showing error: ag_2018 is not defined.
I saw some suggestions using dict, can someone please provide more detail about how to apply it since I am not very familiar with dict. Thanks.