my dataframe is as below, I want to create a new column based on value of column "a" but the value is from "b" and "c"
a b c
1 0.1 2
0 3 0.2
1 0.4 5
I create a function as below, but it's not working.. any idea?
def proba_column(row):
if row["label"] == "1":
val = row["c"]
else:
val = row["b"]
return val
result['proba'] = result.apply(proba_column,axis=1)
expected result should be:
a b c proba
1 0.1 2 2
0 3 0.2 3
1 0.4 5 5