title: Pandas: Number of unique days in a timestamp Series
body: <p>I have Pandas DataFrame with nearly 3,000,000 rows. One of the columns is called <code>TIMESTAMP</code>, and of the datetime64 type. The timestamp format is given below:</p>
  
  <pre><code>2015-03-31 22:56:45.510
  </code></pre>
  
  <p>My goal is calculating the number of days data were collected. My initial approach was simple:</p>
  
  <pre><code>(df.TIMESTAMP.max() - df.TIMESTAMP.min()).days
  </code></pre>
  
  <p>However, it occured to me this may not be always correct, since there is no guarantee data was collected everyday. Instead, I tried counting unique days in the timestamp series using <code>map</code> and <code>apply</code>, and both take a considerable amount of time for 3,000,000 rows:</p>
  
  <pre><code>%timeit len(df['TIMESTAMP'].map(lambda t: t.date()).unique())
  1 loops, best of 3: 41.3 s per loop
  
  %timeit len(df['TIMESTAMP'].apply(lambda t: t.date()).unique())
  1 loops, best of 3: 42.3 s per loop
  </code></pre>
  
  <p>Is there a way to speed up this computation, or an entirely different but better approach?</p>
  
  <p>Thanks!</p>