0

I have this list that has folders names:

scenarios_list=[2020,2021,2022]

I would like to create a dataframe that adds the name of the folder as this:

for i in scenarios_list:
    typology_+i = pd.read_file(path+"\\"+i+"\\"+'data.csv')

so I would have 3 dataframes: typology_2020 typology_2021 typology_2022

Ricardo Gomes
  • 229
  • 1
  • 5
  • either store them in a list, or a dict: `typologies = {"2020": pd.read_file(f"{path}\{i}\data.csv"), ...}` for instance – Florent Monin Mar 27 '23 at 15:10

1 Answers1

0

as buran pointed, this worked:

for i in scenarios_list:
    globals()['typology_{}'.format(i)] =pd.read_file(path+"\\"+i+"\\"+'data.csv')
Ricardo Gomes
  • 229
  • 1
  • 5