Assigning values based on existing numeric values in a column in pandas
df['xyz'] = df.apply(lambda x: 'a' if x['xxx'] <=0 else ('b' if x['xxx'] < 1000 else 'c' ))
there might be syntax errors
I would want to implement the following logic in pandas:
if df['xxx'] <= 0 then df['xyz']== 'a'
if df['xxx'] between 0.5 and 10.97 then df['xyz']== 'b'
if df['xxx'] between 11 and 89.57 then df['xyz']== 'c'
if df['xxx'] > 100 then df['xyz']== 'd'
How can I do this in the simplest way?
Much thanks.