I have a dataframe
dff.head()
+---+----------+-----------------+--------------+------------+
| | owner_id | purchase_points | return_point | push_toke |
+---+----------+-----------------+--------------+------------+
| 0 | 123 | 77.0 | 0.0 | |
| 1 | 546 | 0.0 | 16.0 | Abc97grwe |
| 2 | 789 | 5.0 | 15.0 | cst84ask |
| 3 | 697 | 89.0 | 6.0 | abc7532asd |
+---+----------+-----------------+--------------+------------+
I'm trying to get an status column to say if purchase_point is >0 then say "Purchased", if return point>0 and push_token != np.nan i want "Yes, Never purchased" and rest to say "No"
I tried the below if loop but find below error:
def my_fun(organic, seeded, push_token):
if dff['purchase_points'] > 0:
return 'Yes Answered'
elif [dff['return_point'] > 0 | dff['push_token'] == np.nan]:
return 'Yes, Never answered'
else:
return 'No'
dff['status_1'] = dff.apply(my_fun('organic', 'seeded', 'push_token'))
error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Please help with the solution, thanks in advance