I am new to python so the question I am about to ask is probably very basic but I have been struggling with that for a day and a half so I decided to reach for help.
I am in the middle of a data analysis project for UEFA Euro 2024 (the same as in this video except that instead of using World Cup data I use data from UEFA Euro matches – timestamp of the part that i struggle is 1:53:00 – https://www.youtube.com/watch?v=yat7soj__4w).
The final result is a set of simulations which predicts winner of UEFA Euro 2024.
I am stuck with the part of code that uses “for” loop to insert probability values into a dictionary (“dict_table”) for every stage of the tournament. Up to this point everything is working fine. Every dataframe and dictionary returns correct data. The function that predict points works correctly as well. That is why I assume the problem is somewhere in the following part of code:
for group in dict_table:
teams_in_group = dict_table[group]['Team'].values
df_fixture_group_6 = df_fixture_group_24[df_fixture_group_24['home'].isin(teams_in_group)]
for index, row in df_fixture_group_6.iterrows():
home, away = row['home'], row['away']
points_home, points_away = predict_points(home, away)
dict_table[group].loc[dict_table[group]['Team'] == home, 'Pts'] += points_home
dict_table[group].loc[dict_table[group]['Team'] == away, 'Pts'] += points_away
dict_table[group] = dict_table[group].sort_values('Pts', ascending=False).reset_index()
dict_table[group] = dict_table[group][['Team', 'Pts']]
dict_table[group] = dict_table[group].round(0)
In order to verify if it is not a problem in my software I downloaded exactly the same data and code used by the author of the video and it worked perfectly. Below you can find the data and code used in the video.
https://github.com/thepycoach/fifa-world-cup-2022-prediction
https://drive.google.com/drive/folders/15BeVs7h0zDFHNSmZ0Zwyb92uL5L6woXL
Below you can find my code and files:
https://drive.google.com/drive/folders/1ze0w7vFWCrli32hlDoVtGOcd-WVgEzXf?usp=sharing
Thank you!!
dryzzzy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.