0

Leading on from this question, I have an arbitrary number of dataframes

df1, df2, df3,..., dfn

and I need to apply the same function to each of them. Since I do not know how many data frames there will be, none of the answers apply to my use case, as they involve accessing each data frames via df_list[0], df_list[1], etc. or df_dict['first'], df_dict['second'], etc. afterwards.

How do I do this?

Elis
  • 70
  • 10
  • 1
    Is you question "how to loop over the elements of a list/dictionary"? – mozway Jun 30 '23 at 14:50
  • 1
    How are you getting your dataframes? – Michael Cao Jun 30 '23 at 14:53
  • Are your dataframes part of a list or dictionary? Are they stand alone variables in code, if so, then add them to a list or dictionary and loop to apply your function to each element of that dictionary/list. – Scott Boston Jun 30 '23 at 14:55
  • @mozway Seems sarcastic but no – Elis Jun 30 '23 at 14:56
  • 2
    That wasn't sarcastic. You shouldn't create many dataframes initially, instead store them in a list/dictionary upon creation. See the linked duplicate. – mozway Jun 30 '23 at 15:00

0 Answers0