title: How to drop rows before a datetime variable in pandas?
body: <p>My code returns a completely empty dataframe when I try to select and drop rows before a given datetime. Passing the datetime through as a string works however i need this to be a variable based on the last datetime value of my dataframe.</p>
  <pre><code>In:
  df_transposed['Interval_Date'] = pd.to_datetime(df_transposed['Interval_Date'])
  filter_range_begin = str((datetime.now() - timedelta(hours=2)).strftime(&quot;%Y-%m-%d %H:%M:%S&quot;))
  df_transposed = df_transposed.set_index('Interval_Date')
  indexNames = df_transposed[df_transposed.index.get_level_values(0) &gt; filter_range_begin]
  
  Out:
  Empty DataFrame
  Columns: [0, 1, Label]
  Index: []
  </code></pre>
  <p>Whereas:</p>
  <pre><code>In:
  df_transposed['Interval_Date'] = pd.to_datetime(df_transposed['Interval_Date'])
  filter_range_begin = '2020-09-01 02:00:00'
  df_transposed = df_transposed.set_index('Interval_Date')
  indexNames = df_transposed[df_transposed.index.get_level_values(0) &gt; filter_range_begin]
  </code></pre>
  <p>Returns:</p>
  <pre><code>Out:
                           0    1  Label
  Interval_Date                          
  2020-09-01 02:15:00  401121  NaN    NaN
  2020-09-01 02:30:00  815314  NaN    NaN
  2020-09-01 02:45:00  885369  NaN    NaN
  </code></pre>
  <p>I also need to drop any rows that fall outside of this range.</p>
  <p>Thank you.</p>