Suppose I have a large data block similar to the structure below
home| away| home_score| away_score
A| B| 1| 0
B| C| 1| 1
C| A| 1| 0
I want to find the latest result, regardless of home / away. For example, the last score of teams A, B, and C is 0, 1, and 1, respectively, and is filled back to the original data framework:
home| away| home_score| away_score| last_score_home| last_score_away|
A| B| 1| 0| | |
B| C| 1| 1| 0| |
C| A| 1| 0| 1| 1|
...
I tried group and shift, but I'm not sure how to combine the results at home / at home.
source
share