I want to create a dataframe which name contains a variable. For example:
class = 10
'number'+str(class) = pd.DataFrame([[1,2], [3,4]], columns = ['a','b'])
this code should create a df named "number10":
if I change the variable class to: class = 9, this should create a df named "number9"
The problem is that I cant associate a name to a variable. It is possible with some function? In R I could do it with "assign(paste(...))
Edit I solve the problem! the solution would be:
locals()['number'+str(class)] = pd.DataFrame([[1,2], [3,4]], columns = ['a','b'])
or
globals()['number'+str(class)] = pd.DataFrame([[1,2], [3,4]], columns = ['a','b'])