1
Timedelta值我有大数据帧(DF),它看起来像:
聚集在Python的数据帧
Acc_num date_diff 0 29 0:04:43 1 29 0:01:43 2 29 2:22:45 3 29 0:16:21 4 29 0:58:20 5 30 0:00:35 6 34 7:15:26 7 34 4:40:01 8 34 0:56:02 9 34 6:53:44 10 34 1:36:58 ..... Acc_num int64 date_diff timedelta64[ns] dtype: object
我需要计算“date_diff”平均(以timedelta格式),每个账号。
df.date_diff.mean()
工作正常。但是,当我下一次尝试:
df.groupby('Acc_num').date_diff.mean()
它提出了一个例外:
"DataError: No numeric types to aggregate"
我也试过df.pivot_table()
方法,但没有任何acheive。
有人可以帮助我这个东西。先谢谢你!