Python Pandas datetime64[ns] comparision
<p>I'm trying to use indexing to select rows in my dataframe after the date 2011-01-01. I used following line of code to return only part of dataframe that is after 2011-01-01 </p>

<pre><code>  df = df[df.Date &gt; np.datetime64('2011-01-01 00:00:00')]
</code></pre>

<p>I don't get an error. However, I only see dates that are of 2016 year nothing on 2011. When I manually open file I can see that there are plenty of entries starting with 2011 year.</p>

<p>What do I do wrong here? Any ideas?</p>

<p>Thanks!</p>

<p>Here is a sniped of data:<a href="http://i.stack.imgur.com/YhEa3.jpg" rel="nofollow">enter image description here</a></p>

<p>After importing your data, it looks like all the values of the <code>Date</code> column are still there, even after filtering. It's just that your data is too large to be displayed fully on your console (take a look at <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.set_option.html" rel="nofollow">pandas settings</a>). Therefore some of it is being (visually) truncated to fit the page.</p>

<p>The trick to use convert the <code>Date</code> column to a pandas datetime object and handle the filtering from there:</p>

<pre><code>import pandas as pd

df = pd.read_csv('Crimes_-_2001_to_present.csv', header = 0)
df.Date = pd.to_datetime(df.Date)

filterer = df.Date &gt; pd.to_datetime('2011-01-01 00:00:00')
df = df[filterer]
</code></pre>

<p>Now when you look at the 200th row in the <code>Date</code> column, you should get something:</p>

<pre><code>df['Date'].iloc[200]
#Timestamp('2011-05-31 19:30:00')
</code></pre>

<p>At row 2000 in column <code>Date</code>:</p>

<pre><code>df['Date'].iloc[2000]
#Timestamp('2013-09-19 20:45:00')
</code></pre>

<p>In essence, everything is there. Your console is perhaps too small to fit it all.</p>

<p>I hope this helps.</p>

python datetime pandas