Using python, I've created a dataframe with a datetime index.
datetime_index = pd.date_range(start='2018-01-01', end='2019-12-31', freq='D')
df = pd.DataFrame({}, index=datetime_index)
Now I would like to be able to search through a list of dates, if the date in index is also in the list I've created, I would like a new variable df['fireworks'] to be 1, otherwise 0. I have tried creating a list like this:
fireworks = {'2018-07-04', '2018-07-05', '2018-04-13', '2018-04-18'}
I tried to accomplish this way:
df['fireworks'] = np.where(df.index==fireworks, 1, 0)
All the values of the newly created df['fireworks'] are still 0.
Thanks in advance to anyone helping me with this.