soccerdata icon indicating copy to clipboard operation
soccerdata copied to clipboard

FBRef against stats

Open RobiFera opened this issue 1 year ago • 5 comments

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!

RobiFera avatar Aug 26 '22 20:08 RobiFera

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

probberechts avatar Aug 26 '22 20:08 probberechts

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

RobiFera avatar Aug 26 '22 20:08 RobiFera

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.

probberechts avatar Aug 26 '22 20:08 probberechts

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.

RobiFera avatar Aug 26 '22 21:08 RobiFera

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

RobiFera avatar Aug 26 '22 21:08 RobiFera