python - How to name dataframe with variables in pandas -


is there way generate multiple dataframes in pandas? want name dataframes variables like:

for in range 1 100 dfi in dfs   df1= df2= df3=  : : :  df99= df100= 

i think can use dict comprehension:

n = 101 # 5 in sample dfs = {'name' + str(i):df in range(1,n)} print (dfs) 

sample:

df = pd.dataframe({'a':[1,2,3],                    'b':[4,5,6],                    'c':[7,8,9],                    'd':[1,3,5],                    'e':[5,3,6],                    'f':[7,4,3]})  print (df)     b  c  d  e  f 0  1  4  7  1  5  7 1  2  5  8  3  3  4 2  3  6  9  5  6  3  n = 5 dfs = {'name' + str(i):df in range(1,n)} print (dfs) {'name3':     b  c  d  e  f 0  1  4  7  1  5  7 1  2  5  8  3  3  4 2  3  6  9  5  6  3, 'name4':     b  c  d  e  f 0  1  4  7  1  5  7 1  2  5  8  3  3  4 2  3  6  9  5  6  3, 'name2':     b  c  d  e  f 0  1  4  7  1  5  7 1  2  5  8  3  3  4 2  3  6  9  5  6  3, 'name1':     b  c  d  e  f 0  1  4  7  1  5  7 1  2  5  8  3  3  4 2  3  6  9  5  6  3}  print (dfs['name1'])     b  c  d  e  f 0  1  4  7  1  5  7 1  2  5  8  3  3  4 2  3  6  9  5  6  3 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -