Let say I have some data associated with football
Date Home Away HomeGoal AwayGoal TotalGoal
2019 Arsenal MU 5 1 6
2019 MCity Liv 2 2 4
2019 MU Liv 3 4 7
2019 MCity MU 0 0 0
I want to create a column of data which show the average goals of that team in the recent 2 games. For example in the last row, I want to include a column that shows the average goal of MU in their last 2 games, which = (1+3)/2 = 2.
Is there any functions in python can achieve this?