【发布时间】:2019-05-13 14:42:35
【问题描述】:
嗨,我有下一个数据帧
user_id webpage
1 google
1 bing
2 google
2 google
2 yahoo
我想创建一个这样的结果数据框
user_id google bing yahoo
1 1 1 0
2 2 0 1
它按 id 计算出现次数
我刚刚找到了一种一般计算频率的解决方案,但没有将出现次数放在自己的列中并将计数放在自己的列中。
【问题讨论】:
-
既然你在传播计数,一个更好的副本是:Faster ways to calculate frequencies and cast from long to wide