mardi 16 mars 2021

Super Confusion On If Statement

I am very confused on this one. I have a few formulas that run a base number value and either add or subtract from that base value. The lines of code run fine if I ONLY run the code that subtracts (I have around 7 numbers in each set of data) I can confirm the outputs of only 4 out of 7 subtract, but when I run all four formulas I walk away with a table that everything has +1 added. So everything in my data set has +1, even though when I run this with ONLY the subtract I only adjust the four that meet the condition and it does not execute on the other 3 that do not meet the condition. Why is it adding +1 to all when they do not meet that condition when I add in the 3rd and 4th equations?

    if home_team_shots_on_goal.values / away_team_shots_on_goal.values <= 0.95 or home_team_shots_on_goal.values / away_team_shots_on_goal.values >= 1.05:
        home_team_ppg = home_team_ppg - 0.5

    if away_team_shots_on_goal.values / home_team_shots_on_goal.values <= 0.95 or away_team_shots_on_goal.values / home_team_shots_on_goal.values >= 1.05:
        away_team_ppg = away_team_ppg - 0.5

    if home_team_shots_on_goal.values / away_team_shots_on_goal.values <= 1.05 or home_team_shots_on_goal.values / away_team_shots_on_goal.values >= 0.95:
        home_team_ppg = home_team_ppg + 0.5

    if away_team_shots_on_goal.values / home_team_shots_on_goal.values <= 1.05 or away_team_shots_on_goal.values / home_team_shots_on_goal.values >= 0.95:
        away_team_ppg = away_team_ppg + 0.5

Aucun commentaire:

Enregistrer un commentaire