title: How can I create a pivot table from a resampled column?
body: <p>Suppose I have event data like:</p>
  
  <pre><code>ts,uid
  2016-02-13 20:18:03.000001 UTC,5236965070
  2016-02-13 23:05:08 UTC,2834437228
  2016-02-13 23:13:00.000032 UTC,2206245130
  2016-02-13 22:45:07.000004 UTC,1539535012
  2016-02-13 23:47:44 UTC,3431025028
  2016-02-13 16:42:16.000001 UTC,810825324
  2016-02-13 22:37:14 UTC,2625355144
  2016-02-14 00:31:52.000009 UTC,24815453
  2016-02-12 06:43:40.000007 UTC,3895095040
  2016-02-14 00:09:04 UTC,715095136
  ...
  </code></pre>
  
  <p>How can I create a pivot table of the uid to the event count in the hour? I tried doing</p>
  
  <blockquote>
    <p>DF.groupby(['uid', pandas.TimeGrouper(key='ts', freq='h')], sort=False).count()</p>
  </blockquote>
  
  <p>but I got <code>ValueError: items in new_categories are not the same as in old categories</code>. How can I get it to work? Is using <code>pivot</code> or <code>pivot_table</code> a better approach?</p>