title: Using a list in a mask to filter out dates within a dataframe
body: <p>EDIT: This is NOT a duplicate of the other question. This question is about filtering specific <strong>dates</strong> from a list using a mask. The other question (<em>How to filter Pandas dataframe using 'in' and 'not in' like in SQL</em>) uses a totally different method of df.column.isin(). Furthermore, the other question uses categorical string object data to filter rather than datetime data.</p>
  <p>Here is my attempt with .isin():</p>
  <pre><code>list_dates = [np.datetime64('2018-12-31'),np.datetime64('2019-01-01')]
  df[~df['StartTime'].dt.date.isin(list_dates)]
  </code></pre>
  <p>output:</p>
  <pre><code>    StartTime   Duration    Site
  0   2018-12-30 01:45:00 1   1
  1   2018-12-31 05:48:00 1   2
  2   2018-12-31 17:36:00 3   3
  </code></pre>
  <p>This output is obviously incorrect as in the list, I specified '2018-12-31' to be filtered out.</p>
  <hr />
  <p>I have been learning how to use masks to filter out dates in a dataframe.</p>
  <p>Firstly, here is the dataframe that I am testing on:</p>
  <pre><code>data = {'StartTime':['2018-12-30 12:45:00+11:00','2018-12-31 16:48:00+11:00','2019-01-01 04:36:00+11:00','2019-01-01 19:27:00+11:00','2019-01-02 05:13:00+11:00'],
          'Duration':[1,1,3,1,2],
          'Site':['1','2','3','4','5']    
  }
  
  df = pd.DataFrame(data)
  df['StartTime'] = pd.to_datetime(df['StartTime'])
  </code></pre>
  <p>Next, I am looking to filter out a single date. This works:</p>
  <pre><code>mask = (df['StartTime'].dt.date != np.datetime64('2019-01-01'))
  
  df.loc[mask]
  </code></pre>
  <p>However, I want to do this for multiple dates, and it will be a pain to write the same line for multiple dates. Essentially, I would like to filter out a list of dates. For example, I would like to filter out all public holidays.</p>
  <p>Can I do something like this?</p>
  <pre><code>list_of_holiday_dates = [np.datetime64('2019-01-01'), np.datetime64('2019-12-25')]
  
  mask = (df['StartTime'] != list_of_holiday_dates)
  
  df.loc[mask]
  </code></pre>
  <p>The reason being, the list will be something that needs updating regularly as public holidays are on different dates depending on the year.</p>
  <hr />
  <p>AND just a second question for curiosity sake; Why is it when you make a mask you use <code>dt.date</code> , <code>dt.hour</code>, etc.</p>
  <pre><code>mask = (df['StartTime'].dt.date != np.datetime64('2019-01-01'))
  </code></pre>
  <p>BUT when you select/index it directly, you can't use .dt</p>
  <pre><code># this works
  df.iloc[0].StartTime.date
  # this works
  df.iloc[0].StartTime.dt.date()
  # this doesn't work, but is used in the mask
  df.iloc[0].StartTime.dt.date
  
  # this works
  df.iloc[0].StartTime.hour
  # this doesn't work, but would be used in the mask
  df.StartTime.dt.hour.between(6,9)
  </code></pre>