Ok I have a dataset regarding game outcomes that is incomplete and I want to generate a plot with either the data present or zero values for the players that have no data in that game. Furthermore I want to add the data present via a list: some players are attackers and some defenders My data is like this:
raw data:
Game Player Goal Assits Fouls
1 Alpha 1 1 0
1 Beta 2 0 1
2 Alpha 0 1 1
2 Gamma 2 0 0
3 Beta 3 0 1
4 Alpha 1 1 1
4 Beta 2 0 1
5 Alpha 0 1 1
5 Beta 1 0 0
5 Gamma 0 1 1
desired result with Points for Goals + Assists and Attackers = ['Alpha','Beta'] and Defenders=['Gamma']
Game Attackers Defenders
1 4 0
2 1 2
3 3 0
4 4 0
5 2 1
I have all the raw data in a pandas dataframe and I have tried using isin function to get the data out. This leaves me with different length results, ie if it is "not in" then there is no data added. I would (as shown just like zeros instead . ==> ie in Game 1 Gamma is not mentioned so he has zero points.
thank you for your help