Reputation: 742
I have a lot of dataframes which are sequentially named in the format "set1", "set2", "set3" ....
I need to run a for loop across all the dataframes to carry out various operations in this dataframes.
How will I convert the string "set1" to the dataframe set1 so that I can carry out operations like set1.index, set1.columns e.t.c
Upvotes: 0
Views: 45
Reputation: 463
Depending on whether the variables are located in the global environment or are local to the scope you are working in, you can use
## access global variable by string name
globals()['set1']
## access local variable by string name
locals()['set1']
Upvotes: 1