Let's say multiple soccer matches are being played. A datapoint is generated when a team has lost possession of the ball and the duration of possession is recorded in a text file like so:
'Game','Country','Team','Ball Possession Interval (sec)'
1,Croatia,A,9
2,France,B,11
1,Croatia,A,8
4,Spain,C,10
1,Croatia,B,6
2,France,B,7
3,Germany,C,12
2,France,A,8
...
Game is a count of games thus far played by a team. For example 2,France,B,7 means that team B from France, now on their 2nd game, has just lost possession of the ball after a duration of 7 seconds.
I would like a plot grouped by country (a subplot for each country), with teams along the axis, and a boxplot of the sum of 'Ball Possession Interval (sec)' per game per team. I tried the following,
df.groupby('Country').boxplot(by='Team',column=*vector of sum of ball possession intervals per game*)
but I don't know what to set column to. I wish I could set it to the following,
df.groupby(['Country','Team','Game'])['Ball Possession Interval (sec)'].sum()
but it doesn't work.
Is there a simple way to do this?
