How to Filter Out Today's Date in Pandas Dataframe
<p>I have the following data frame:</p>

<pre><code>Company     Date                 Value
ABC         08/21/16 00:00:00    500
ABC         08/22/16 00:00:00    600
ABC         08/23/16 00:00:00    650
ABC         08/24/16 00:00:00    625
ABC         08/25/16 00:00:00    675
ABC         08/26/16 00:00:00    680
</code></pre>

<p>If we assume that 26-August-2016 is today's date, then I would like to create a new data frame that effectively excludes the data in the 08/26/16 row.</p>

<p><strong>EDIT:</strong>
Here's my code to do so:</p>

<pre><code>today = time.strftime("%m/%d/%Y")
df.Date = df.Date &lt;&gt; today
</code></pre>

<p>Unfortunately, I see an error message indicating:</p>

<pre><code>'Series' object has no attribute 'Date'
</code></pre>

<p>Any idea how to resolve this?</p>

<p>Thanks!</p>

<p><strong>SOLUTION:</strong></p>

<pre><code>today = time.strftime("%Y-%m-%d")

df = df.loc[(df.Date &lt; today)]
</code></pre>

<p>I think you want to filter the dates that appear earlier than your specified date, though the title seems misleading. You must convert the <code>Date</code> column which are of dtype <code>object</code> to <code>datetime64</code>.</p>

<pre><code>In [22]: df['Date'] = pd.to_datetime(df['Date'], format='%Y-%m-%d')

In [23]: today = datetime.strptime('08/26/16', '%m/%d/%y')

In [24]: today
Out[24]: datetime.datetime(2016, 8, 26, 0, 0)

In [25]: df = df.loc[(df['Date'] &lt; today)]

In [26]: df
Out[26]: 
  Company       Date  Value
0     ABC 2016-08-21    500
1     ABC 2016-08-22    600
2     ABC 2016-08-23    650
3     ABC 2016-08-24    625
4     ABC 2016-08-25    675
</code></pre>

python datetime pandas