【发布时间】:2017-09-20 22:12:57
【问题描述】:
我有一个 python 数据框有三列。
a b c
0 1 2 3
1 1 2 3
2 1 2 8
3 1 5 9
4 1 3 7
5 1 3 4
我想找到a,b,c的所有组合,我的预期结果是这样的:
[1,2,3]: 2 # from row 0 and row 1
[1,2] : 3 # from row 0 and row 1 and row 2
[1,3] : 4 # from row 0, 1, 4, 5
[1,4] : 1
[1,5] : 1
[1,7] : 1
[1,8] : 1
[1,9] : 1
[2,3] : 2
............
随意使用任何包。
import pandas as pd
pd.DataFrame(data=[[1,2,3],[1,2,3],[1,2,8],[1,5,9],[1,3,7],[1,3,4]],columns=['a','b','c'])
【问题讨论】: