Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Pandas label column based on one condition
- df['new_column'] = np.where((df['target_column'] == 'condition'), 'Foo', 'Bar') # if `Foo` first val, else `Bar` second value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement