Read multiple csvs into multiple dataframes in Pandas

前端 未结 1 1776
情话喂你
情话喂你 2020-12-19 14:46

Is there a way to read multiple csv files into Pandas through a loop and define them as such?

for i in [\'a\', \'b\', \'c\', \'d\']:
    csv_(i) = pd.read_c         


        
相关标签:
1条回答
  • 2020-12-19 15:10

    You can use dict comprehension for dict of DataFrames:

    dfs = {i: pd.read_csv('C:/test_{}.csv'.format(i)) for i in ['a', 'b', 'c', 'd']}
    
    print (dfs['a'])
    
    0 讨论(0)
提交回复
热议问题