'Is it possible to put this np.where function in a loop?
I'm trying to move all values in the data frame that contains "Applicant Age" data (there is only one "Applicant Age" value per row) into a new column "applicant_age", but there are 17 columns that I have to iterate over to find them - the data is all mixed up at the moment.
df_merged['applicant_age'] = np.where(df_merged.rule0_evaluationstring.str.contains('Applicant Age'),
df_merged['rule0_evaluationstring'],
df_merged['applicant_age'])
I'm using an np.where function, and it is giving me the desired result, but now I have to change the number in "rule0_evaluationstring" from 0 - 16 to go through all 17 columns.
Is there a loop that I can use to automate this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
