Consider the case where I have three dataframes, that are called df1, df2 and df3.
df1 has 5 columns: x1, x2, x3, age, height. df2 has 3 columns: x1, x2, weight. df3 has 4 columns: x1, x2, x3, bmi.
For each of these dataframes, I want to create a list of the demographic variables e.g.
df1_demographics=['age', 'height']
df2_demographics=['weight']
df3_demographics=['bmi']
I want to be able to call the list in a loop in the following way:
for dataset in df1, df2, df3:
print(dataset_demographics)
My actual loop is very long and I need to loop through the dataframes. That's why I specifically want a way of calling the lists within a for loop looping through the dataframes.
The desired output of this loop would be
['age', 'height']
['weight']
['bmi']