I need help with an assignment

We have a data set containing home teams and away teams of a soccer league and they are ordered to make it such that: away teams/ home team/result(A,H or D) i need to calculate the points of each team such that H is three points if they are a home team and A is 3 points if they are a local team and D is 1 points in both. And then ai need to add them as columns to the dataset frame. I managed to calculate the sum of points individually but I can’t think of a way to do it in a loop that calculates all the teams then add it to the dataset as columns

1 Like

You’re merely figuring out how many points a team earns in a soccer league, which is usually scored with three points for a victory, one point for a draw, and zero for a loss. Although it’s unclear from your description of the data, it appears that you have all of the fixtures from a season and are attempting to determine each team’s final score.

From a whiteboard perspective, I would begin like this:

Make a dictionary with the team names as the keys and initial values of 0.

Go through every row in your dataset one by one. Add three points to the home team’s point total in your lexicon if the outcome is H.Add one point to both home and away if the result is D.

You’ll have a dictionary in the end, with the team names serving as the keys and the point totals as the values.

1 Like

There’s a lot that seems unclear about this assignment. Why not just list the assignment exactly instead of paraphrasing it?

1 Like

Because he gave us instructions verbally rather than by turning in a description of the task.

If you’re ready to assist me, I can go into further detail and even show you the dataset.

1 Like

Having the dataset would help but your description still doesn’t make a ton of sense.

For instance,

i need to calculate the points of each team such that H is three points if they are a home team

Are you saying that if team TeamA is the home team, then TeamA has 3 points added to its total, or something else? And what does “D is 1 points in both” mean?

1 Like

Each fixture is represented by two vectors, each of which has twenty teams. For instance, if Madrid is the home team and Barcelona is the away team, and the outcome is H, it indicates that Madrid won. D, on the other hand, indicates that both the home and the away teams receive one point for drawing.

1 Like

Two vectors of what? What’s packed into each vector?

Like does the vector have entries (A, B, H) where A is the home team, B is the away team, and H is the result of the game?

Or is there some sort of “Home team” vector and “Away team” vector?

Very fuzzy. Is there a reason you’re not just pointing people to the dataset at the beginning?

1 Like

I don’t have a link to it I have to send by e mail in order to let them access it If you want me to send me your e mail in a dm