Okey a different approach for the same problem. I have the same results but instead of points i have a value for either home win (H), draw (D) or away win (A). A win is 3 points for the winning team and draw is 1 point to both teams. I need the cumulative points for both the home and the away team.
This is the dataframe:
This is the dataframe:
df = pd.DataFrame([ ["Gothenburg", "Malmo", 2018,"A"], ["Malmo","Gothenburg", 2018, "D"], ["Malmo", "Gothenburg", 2018, "A"], ["Gothenburg", "Malmo", 2018, "H"], ["Gothenburg", "Malmo" ,2018, "D"], ["Gothenburg", "Malmo", 2018, "A"], ["Gothenburg", "Malmo", 2018, "H"], ["Malmo", "Gothenburg", 2018, "A"], ["Gothenburg", "Malmo", 2018, "H"], ["Malmo", "Gothenburg", 2018, "H"], [ "Malmo","Gothenburg", 2018, "D"], [ "Malmo", "Gothenburg",2018, "H"], ])And this is desired output:
Hometeam Awayteam Year Tecken H_points A_points 0 Gothenburg Malmo 2018 D Nan Nan 1 Malmo Gothenburg 2018 D 1 1 2 Malmo Gothenburg 2018 A 2 2 3 Gothenburg Malmo 2018 D 5 2 4 Gothenburg Malmo 2018 A 6 3 5 Gothenburg Malmo 2018 D 6 6 6 Gothenburg Malmo 2018 A 7 7 7 Malmo Gothenburg 2018 A 10 7 8 Gothenburg Malmo 2018 D 10 10 9 Malmo Gothenburg 2018 A 11 11 10 Malmo Gothenburg 2018 D 11 14 11 Malmo Gothenburg 2018 A 12 15Im losing my hair over this, hope someone can give me a hand :)