I have two datetime columns in different dataframes, one of general dates and one of holiday dates. I want to add a new column to the first dataframe stating whether or not the date in that row is a holiday.
df = pd.DataFrame({'date': [pd.Timestamp("2018-01-01"), pd.Timestamp("2018-01-02")]})
holidays = pd.DataFrame({'date': [pd.Timestamp("2018-01-01"), pd.Timestamp("2018-12-25")]})
This is my current method:
holiday_dates = holidays.date
df['holiday'] = df.date.map(lambda x: sum(holiday_dates.isin([x])) > 0)
It works, giving the desired output below but is incredibly slow for my data set of around 100,000 entries.
In[]: df
Out[]:
date holiday
0 2018-01-01 True
1 2018-01-02 False
Is there a more efficient way of doing this operation?