python - Parameterized pandas data frame names -
how create data frame name resolves variable? example below created dataframe pd0,pd2..pd10
for in range(0,10): pd + "i" = pd.dataframe()
option 1
in opinion, better track them in dictionary.
dfs = {'pd{}'.format(i): pd.dataframe() in range(10)}
access them
dfs['pd0']
option 2
if insist on placing names namespace
for in range(10): exec('pd{} = pd.dataframe();'.format(i))
option 3
or without exec
for in range(10): locals()['pd{}'.format(i)] = pd.dataframe()
Comments
Post a Comment