I want to create a new column that returns a value if it matches criteria is both columns of an existing df.
df = pd.DataFrame({
'first_column': [1, 2, 3, 5],
'second_column': [10, 20, 30, 50]
})
df.loc[df.first_column <= 3, 'new_column'] = 'good'
df.loc[df.first_column == 1, 'new_column'] = 'bad'
df.loc[df.first_column >= 4, 'new_column'] = 'great'
This works for one condition (though I assume there is a way to say between 2 and 3 which is what I really want for the first line)
But I can't figure out how to get it do so something where I could say if df.first_column >= 4
AND df.second_column >= 50
= 'super great'