我有两列数据框。一个是status
- 这是一列给出状态的人,另一列是comment
列,其中列出了以状态发表评论的人员
status comment
A [B,C,D,E,A....... xy,yz] # `A` gave a status
A [B,L] # `A` gave another status
B [C,D]
L [A]
现在我想要一个类似下面的表格:
A-->B = 2 # as `B` gave two comments in two status of `A`
A-->C = 1
A-->D = 1
A-->E = 1
A-->L = 1
B-->A = 0 # as `A` never gave any comment in status of `B`
L-->A = 1
我可以做一个强力方法。循环每个状态并更新每个邻接列表,但场景是,有数百万行。所以,寻找一个好方法。