Question
I am having trouble figuring out how to create new DataFrame column based on the values in two other columns. I need to use if/elif/else l
Adding to np.where solution :
df['col1']= np.where(df['col'] < 3, 1,np.where( (df['col'] >3 )& (df['col'] <5),2,3))
Overall Logic is :
np.where(Condition, 'true block','false block').
With each true/false block can in turn again be nested.
Also, Notice the & for ANDing! (not 'and')
&
ANDing! (not 'and')