Pandas - Dropping DataFrame rows based on Datetime column value
<p>I am currently writing a script where I want to drop some rows of my pandas dataframe according to Datetime values over several years (I want to drop rows where datetime is between February and May. So, I first tried the following code:</p>

<pre><code>game_df['Date'] = game_df[(game_df['Date'].dt.month &lt; 2) &amp; (game_df['Date'].dt.month &gt; 5)]
</code></pre>

<p>It gave me the same dataframe with NaN values in the 'Date' column over this period of time. So I tried the following code in order to drop the corresponding rows:</p>

<pre><code>game_df['Date'] = game_df[(game_df['Date'].dt.month &lt; 2) &amp; (game_df['Date'].dt.month &gt; 5)].drop(game_df.columns)
</code></pre>

<p>But it raised an error like: labels [u'<strong>Date</strong>' u'<strong>other_column1</strong>' u'<strong>other_column2</strong>' u'<strong>other_column3</strong>' u'<strong>other_column4</strong>'] not contained in axis</p>

<p>Does anyone can solve this problem?</p>