【发布时间】:2017-04-04 10:10:52
【问题描述】:
我在 pandas df 中有一张桌子
product_id_x product_id_y
1 2
1 3
1 4
3 7
3 11
3 14
3 2
and so on around (1000 rows)
我想找出每个 product_id_x 与 product_id_y 的组合数。
即。 1 与 1-2,1-3,1-4 有组合(共 3 个组合) 同样 3 共有 4 种组合。
并创建一个具有
的数据框df2product_id_x combinations
1 3
3 4
and so on ..(distinct product_id_x's)
我应该遵循什么方法? 我在 python 上的技能处于初级水平。 提前致谢。
【问题讨论】:
标签: python python-2.7 python-3.x pandas