I am trying in following was
import numpy as np
conditions = [
(dfyz['year_x'] < datetime.now().year),
((dfyz['year_x'] == datetime.now().year) and (dfyz['mon'] < datetime.now().month)),
(dfyz['year_x'] > datetime.now().year),
((dfyz['year_x'] == datetime.now().year) and (dfyz['mon'] >= datetime.now().month))
]
values = [dfyz['yhat']*dfyz['pct'], dfyz['yhat']*dfyz['pct'], dfyz['yhat']*dfyz['pct_ft'], dfyz['yhat']*dfyz['pct_ft']]
dfyz['pred_n'] = np.select(conditions,values)
but i am getting following error
f"The truth value of a {type(self).__name__} is ambiguous.
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
i have tried in another way also and posted in stackoverflow but there was no success so far if else not checking both of the conditions in Python
Aucun commentaire:
Enregistrer un commentaire