0
假設我有事件數據,如:如何從重採樣列創建數據透視表?
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
...
如何創建UID的數據透視表,一個小時內,事件計數?我想這樣做
DF.groupby([ 'UID',pandas.TimeGrouper(鍵= 'TS',FREQ = 'H')],排序=假).Count之間()
但我得到了ValueError: items in new_categories are not the same as in old categories
。我怎樣才能使它工作?是使用pivot
還是pivot_table
更好的方法?