Reputation: 519
I have the below data frames loaded :
Now I get a user input value as 1000-2000. Based on the user input value I need to work on respective data frame. In this case, I need to work on : df_1000-2000
How to select the data frame dynamically based on user input and start working on it ?
Upvotes: 0
Views: 291
Reputation: 164783
You should restructure how you store and access your dataframes. First define a dictionary:
dfs = {'1000-2000': df_1000-2000, '3000-4000': df_3000-4000, etc.}
Then taking a user input and using it to query your dictionary is straightforward:
value = input('Input the range you require, e.g. 1000-2000:')
res = dfs[value]
Upvotes: 1