I want to call on a list of questions that are structured the same way (e.g. E1_1, E1_2, E1_3, etc.) in a for loop
Example:
list_of_questions = ['E1', 'E2', 'E3'] # each question in list has associated questions 'E1_1', 'E1_2', 'E1_3', 'E2_1', 'E2_2', 'E2_3', etc.
for question in list_of_questions:
for i in range(1,3):
df['E1_i'] = df['E1_i'] == 1
I know this can be done in Stata via `i' syntax, but I'm wondering if the same can be done in Python.
Thanks!
Aucun commentaire:
Enregistrer un commentaire