python - Most efficient approach to finding common opponents pandas -
i have pandas dataframe match results, i'm trying calculate stats between players based on common opponents. i'm struggling think of efficient approach. i'm doing generating dictionary players keys , values set of players have played against. next step generating dictionary key pair of players , values opponents have had in common , iterate on df, filter df on matches played in past , on matches played between 1 of players , 1 of common opponents. works not fast. i'm aware never fast feel there better approach. here sample:
winner loser date other stats b 1-1-13 xx c 1-2-14 xx b 2-2-14 xx c d 1-3-14 xx c 2-3-14 xx d 3-3-14 xx
so common opponents set be:
a,b: {} a,c: {d} a,d: {c} b,c: {a} b,d: {a} c,d: {a}
stats things average win%
Comments
Post a Comment