******Rev 00******
In Python, I'm trying to define a list of dataframes and name them after a list. These lists represent conditions and models.
ListA=['AA', 'BB', 'CC']
ListB=['s1', 's2', 's3']
I am able to create a string with the content of the list. I'm also able to get the data I need based on this list.
str(ListA[0]) + '_' + str(ListB[0])
However, I can't find a way to declare this as a variable name. Basically, this is the result that I want:
AA_s1 = stuff
If I try the following, it returns a string.
List[0] + '_' + ListB[0]
List[0] + ListB[0]
And if I try something simple like this, it just replaces the value (which is expected actually).
List[0] = stuff
Ultimately, I will create a function with for
that will read all data frames that I need. That's why I want to control the variable names this way, instead of writing them down one by one. I believe that the key is to find the equivalent of str(data)
. I looked into the documentation and I cannot find anything similar to var
, ToVar
or something similar. Note that I do not have programming skills and I don't know any other language, which limits a bit my ability to research this.
Thanks
******Rev 01******
The thread is marked as a duplicate with this question. I went through the thread, and I found out that I can store the variables into a dictionary, I still cannot recall the data using the initial lists that I had.
Ultimately, my goal is to write:
ListA[i] + '_' + ListB[i]
#where i is variable from 0 to ...
#Syntax above is most likely incorrect.
and get the data frame stored into that. The name of the data frame is AA_s1, and it is accessible using:
dic['AA_s1']
However, I am still forced to write down manually the name of the variable that I am working with.
In an answer below, it is suggested that what I am trying to accomplish is impossible. If so, then please confirm.