I have a query in my code, where am trying to use if else case to derive a value in a data frame,
import pandas as pd
import numpy as np
c=15
s={'yr':[2014,2014,2014,2014],'value':[10,20,20,50]}
p=pd.DataFrame(data=s)
if (p['value'])>= c:
p['qty']=c-p['value']
else:
p['value']
I am getting the error in the above code-
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Basically this should be my expected output-
yr value qty
0 2014 10 10
1 2014 20 5
2 2014 20 5
3 2014 50 35
How should I solve this error?
p['value'] - cinstead ofc - p['value']?