Count
League Result
EPL H 16
D 9
A 10
Champ H 67
D 15
A 57
H 87
La Liga D 35
A 40
I have a breakdown of football results for different leagues and a count of how many times that result occurred.
I want to see the proportion of home wins, draws, away wins as a percentage of the total games played. I have seen a solution to this below:
df.groupby("League").apply(lambda g: (g/g.sum()*100)
At first glance, this made sense, but what exactly is g
here? I assumed it was the H, D or A count and then the g.sum()
summed all of the H,D,A counts grouped by each division. But, if g
is just a value, how are we calling the method g.sum()
? What exactly is g
here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…