0

I have multiple csv files, named "csv_i", where i varies from 1 to 54. I want to create a for loop to read each one of these csv files in a similarly named dataframe (e.g. df_i), as such:

it = np.arange(1,55)
for i in it:
    my_csv = ('csv_{}.csv'.format(i))
    df_i = pd.read_csv(my_csv)

Can you help me with the last line of the code please? I cannot use something like: "df_{}.format(i) = pd.read_csv(my_csv), so I was wondering how I can achieve it.

Please note, that I saw somewhere that you can create a dictionary and each pair of key-values will be each one of the 54 df, but I'd prefer to have 54 separate dfs instead. Thanks

2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.