matches_to_coplays
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
matches_to_coplays [2023/02/24 16:51] – [problem description] admin | matches_to_coplays [2023/02/24 17:03] (current) – [Solution] admin | ||
---|---|---|---|
Line 104: | Line 104: | ||
Groupby on player_id1, player_id2 and get the size of each group | Groupby on player_id1, player_id2 and get the size of each group | ||
< | < | ||
- | In [4]: | + | In [9]: |
- | df.merge(df, | + | df.merge(df, |
- | Out[4]: | + | .groupby([' |
+ | .size() | ||
+ | Out[9]: | ||
player_id1 | player_id1 | ||
a | a | ||
Line 117: | Line 119: | ||
b 1 | b 1 | ||
c 2 | c 2 | ||
+ | dtype: int64 | ||
</ | </ | ||
We want player_id1 and player_id2 as columns instead of as index. | We want player_id1 and player_id2 as columns instead of as index. | ||
< | < | ||
- | In [5]: | + | In [11]: |
- | df.merge(df, | + | df.merge(df, |
- | Out[5]: | + | .groupby([' |
+ | .size() | ||
+ | Out[11]: | ||
player_id1 player_id2 | player_id1 player_id2 | ||
0 a a 2 | 0 a a 2 | ||
Line 136: | Line 141: | ||
</ | </ | ||
+ | See also: | ||
+ | * https:// | ||
+ | * It is worth going through this page in its entirety. | ||
+ | * I got the answer from here. I just added some intermediate steps to understand what is going on behind the scenes. | ||
+ | * It shows some alternative solutions which are worth exploring. | ||
+ | * It shows how to get the adjacency matrix | ||
+ | * It also shows how to visualize the result with some cool graphs produced by the networkx package. | ||
matches_to_coplays.1677257473.txt.gz · Last modified: 2023/02/24 16:51 by admin