I am trying to create a new column based on the multiple conditions shown in my code. I have a dictionary for jp_hol which has the holidays in japan and my dataframe has the that date column which is a string, and all other columns used in the function I however get this error below could someone help me figure out the problem
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
my code:
def flag():
if (load['date'].isin([i for i in jp_hol.keys()]) |(load['day_of_week_int']==6)):
l='holiday'
elif load['day_of_week_int'].isin([i for i in range(0,5)]):
l='weekday'
elif load['day_of_week_int']==5:
l='sat'
return l
load['flag']=load.apply(flag(),axis=1
Note: if the holiday falls in a weekday then the holiday should take precedence over weekday.