Reputation: 31
I have a dataframe for which I want to create a new column called result which should take the value "refuse" if the value of the column "mean" is less than 10 otherwise the refuse column should take the value "Admitted".
[
Upvotes: 0
Views: 53
Reputation: 1875
data.loc[(data['mean'] < 10), 'result'] = 'Refuse'
data.loc[(data['mean'] >= 10), 'result'] = 'Admitted'
Upvotes: 0
Reputation: 6574
Here you go:
import numpy as np
data['new_col'] = np.where(data['mean'] < 10, 'refuse', 'Admitted')
Upvotes: 1