[GH-ISSUE #78] [FBref] Team against stats #15

Closed
opened 2026-03-02 15:55:01 +03:00 by kerem · 5 comments
Owner

Originally created by @RobiFera on GitHub (Aug 26, 2022).
Original GitHub issue: https://github.com/probberechts/soccerdata/issues/78

Hi! First of all, thank you for the code!

I'd like to ask if it would be possible to also get stats from the "Opponent Stats" table,
Thanks!

Originally created by @RobiFera on GitHub (Aug 26, 2022). Original GitHub issue: https://github.com/probberechts/soccerdata/issues/78 Hi! First of all, thank you for the code! I'd like to ask if it would be possible to also get stats from the "Opponent Stats" table, Thanks!
kerem 2026-03-02 15:55:01 +03:00
Author
Owner

@probberechts commented on GitHub (Aug 26, 2022):

I am not sure to which table you are referring. Can you provide a link?

<!-- gh-comment-id:1228926390 --> @probberechts commented on GitHub (Aug 26, 2022): I am not sure to which table you are referring. Can you provide a link?
Author
Owner

@RobiFera commented on GitHub (Aug 26, 2022):

yep, so for example when viewing the league stats and scrolling down to the various team stats tables, there is an option to switch to an "Opponent Stats" table.

https://fbref.com/en/comps/11/Serie-A-Stats

Capture

<!-- gh-comment-id:1228929143 --> @RobiFera commented on GitHub (Aug 26, 2022): yep, so for example when viewing the league stats and scrolling down to the various team stats tables, there is an option to switch to an "Opponent Stats" table. https://fbref.com/en/comps/11/Serie-A-Stats ![Capture](https://user-images.githubusercontent.com/31993778/186987299-bd1accb4-1760-4045-bee4-9c22a515b445.JPG)
Author
Owner

@probberechts commented on GitHub (Aug 26, 2022):

No, that is currently not implemented. It is a good suggestion, though! I will probably add it at some point, but it might take a while until I find the time time to do so. Feel free to implement it yourself and create a PR.

<!-- gh-comment-id:1228932226 --> @probberechts commented on GitHub (Aug 26, 2022): No, that is currently not implemented. It is a good suggestion, though! I will probably add it at some point, but it might take a while until I find the time time to do so. Feel free to implement it yourself and create a PR.
Author
Owner

@RobiFera commented on GitHub (Aug 26, 2022):

It seems that, in fbref.py on read_team_season_stats(), just need to replace "_for" at the end of the table url with "_against".

I personally don't want to create a PR yet because I'd like to test it more, and I haven't worked with it yet :D but this solution seems simple enough and works at first glance.

<!-- gh-comment-id:1228943024 --> @RobiFera commented on GitHub (Aug 26, 2022): It seems that, in fbref.py on read_team_season_stats(), just need to replace "_for" at the end of the table url with "_against". I personally don't want to create a PR yet because I'd like to test it more, and I haven't worked with it yet :D but this solution seems simple enough and works at first glance.
Author
Owner

@RobiFera commented on GitHub (Aug 26, 2022):

Those are the lines where I changed "_for" to "_against"

github.com/probberechts/soccerdata@50f6fef099/soccerdata/fbref.py (L193)
github.com/probberechts/soccerdata@50f6fef099/soccerdata/fbref.py (L196)

Note that, from what I've seen, only teams have that "Opponent Stats" table

<!-- gh-comment-id:1228949258 --> @RobiFera commented on GitHub (Aug 26, 2022): Those are the lines where I changed "_for" to "_against" https://github.com/probberechts/soccerdata/blob/50f6fef099761a9fca692dbebb96459fba8b393b/soccerdata/fbref.py#L193 https://github.com/probberechts/soccerdata/blob/50f6fef099761a9fca692dbebb96459fba8b393b/soccerdata/fbref.py#L196 Note that, from what I've seen, only teams have that "Opponent Stats" table
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/soccerdata#15
No description provided.