I am trying to create a point system of NFL teams calculating points based on wins and losses relating to how many points they win by and the strength of their opponent.
I have the following df:
Any help would be appreciated
Matt
I have the following df:
Output:Date Visitor Home Visitor Score Home Score
11/14/2021 Minnesota Vikings Los Angeles Chargers 27 20
11/14/2021 Philadelphia Eagles Denver Broncos 30 13
11/14/2021 Seattle Seahawks Green Bay Packers 0 17
11/14/2021 Kansas City Chiefs Las Vegas Raiders 41 14
11/15/2021 Los Angeles Rams San Francisco 49ers 10 31
my current thinking about how to calculate the points according to how many points they win by is the following: gb = 0 for game in range(len(nfl_df)): if nfl_df['Visitor'][game] == 'Green Bay Packers' and nfl_df['Visitor Score'][game] - nfl_df['Home Score'][game] < 9 and nfl_df['Visitor Score'][game] - nfl_df['Home Score'][game] > 0: gb += 3 elif nfl_df['Visitor'][game] == 'Green Bay Packers' and nfl_df['Visitor Score'][game] - nfl_df['Home Score'][game] < 17 and nfl_df['Visitor Score'][game] - nfl_df['Home Score'][game] > 8: gb += 5 elif nfl_df['Visitor'][game] == 'Green Bay Packers' and nfl_df['Visitor Score'][game] - nfl_df['Home Score'][game] > 16: gb += 7 else: passbut if I were to do this with each team it would be a lot of code and I'm sure there is a simpler way to do it. But also, I don't know how to incorporate the strength of the opponent because variable 'gb' has no connection to the string value 'Green Bay Packers' which appears in the df. After each week I would like to have a team's points updated based on their win/loss for that week and incorporate that number into the win/loss calculation. For example, if Green Bay beats Dallas (a team with 50 points) I would have the points from the victory multiply by the total points the opponent has (3*50). I'm just stuck on how to reference the teams' names in the df ('Green Bay Packers', 'Dallas Cowboys') to their point variables (gb, dal)
Any help would be appreciated
Matt