其实pandas就是dataframe,spark里面的是一样的,有些处理方法可以相互借鉴,也可能会有SQL的一些用法,但今天就事论事,不展开。
For Recommendation in Deep learning QQ Group 277356808 For deep learning QQ Second Group 629530787I'm here waiting for you
1-统计每个用户的点击序列数
先给出一个高大上的操作,这一步很关键。
df4=df.groupby('user_id')['item_id'].agg(list)>>> for u in df4: print(u,len(u)) [13, 11, 23, 4, 7, 28, 10, 0, 16, 25, 21, 15, 26, 20, 14, 3, 5, 12, 1, 24, 9] 21[10, 22, 14, 16, 26, 29, 27, 24, 28, 20, 25, 15, 13, 8, 7, 6, 23, 9, 18] 19[12, 16, 2, 22, 15, 14, 13, 6, 1, 10, 25, 8, 19, 0,