lagging experience using Python gives me hard time to get this loop done. This is the dataframe https://1drv.ms/u/s!AlPw3RIiTz1ChRo9YO4kYCI7n0r0?e=OeiLgx.
I would like to have one more column ( 'customer_type') containing string description (either 'New_Guest', 'Repetative with cancelations', 'Repetative NO cancelations'). Conditions to be met :
- New_Guest - 'is_repeated_guest' ==0 AND 'previous_cancellations'==0
- Repetative with cancelations - 'is_repeated_guest' ==1 AND 'previous_cancellations' > 0
- Repetative NO cancelations - 'is_repeated_guest' ==1 AND 'previous_cancellations'==0
I tried the first conditions without succes
for i in df_test.loc[:,'customer_type'] : if ((df_test['is_repeated_guest']==0) & (df_test['previous_cancellations']==0)).all() : df_test.loc[:,'customer_type'] = 'New Guest' else : df_test.loc[:,'customer_type'] = 0
Does anyone have any suggestions ?