I have a dataframe (DF) with size (2000 rows x 10 columns).
The structure of the code is multiple nested if conditions:
DF['NewColumn']=''
for i in range (0, len(DF))
if condition
define variable etc
if condition
DF['NewColumn'].values[i]= some value
else:
DF['NewColumn'].values[i]= some value
etc
Basically, I loop over each row of the dataframe, check the conditions and populate each row of a new column according to the set of if conditions.
Apologies if my question is not specific enough but I am looking for way to code this problem more efficiently. I am keen to hear your thoughts.
Can i use a class or vectorise? I am not sure how to restructure my problem
Many Thanks
Aucun commentaire:
Enregistrer un commentaire