Skip to main content

FBREF2PANDAS - Export FBRef data to Pandas Dataframe

A scraper that directly gives football(not soccer) data from FBRef website directly to Pandas dataframe. Major teams and leagues supported.

Project Repository

Contribute to the Project so that everyone can benefit from it.

Disclaimer : This package in no way tries to take away from the work of FBRef.com I love that website and just needed a package that makes my life easier

To install the package(it just requires pandas !!) :

pip install fbref2pandas

After installation, create a MatchLogsLink object by providing it the following arguments(in str format) :

  • team_id : The identifier of the team. Generally, as I have noticed, fbref uses a particular id for each of the team. It is a 8 character string that uniquely identifies a football team. See this table for id of some popular teams.
Team ID Team Name
'206d90db' 'Barcelona'
'53a2f082' 'Real-Madrid'
'db3b9613' 'Atletico-Madrid'
'e31d1cd9' 'Real-Sociedad'
'2a8183b3' 'Villarreal'

Just copy the team_id and pass as the first argument.

  • year : The year for which the data is required. The year is in the format 2022-2023(for 2022-23 season). Pass this as second argument in the MatchLogsLink object.

  • comp_id : The comp_id is also one of the variables that fbref maintains internally, as far as I can deduce. The comp_id is of the form cXXX, and can be found from the fbref website. See this table below for some common comp_id

Comp ID Competition Name
'c8' 'Champions-League'
'c12' 'La-Liga'
'c19' 'Europa-League'
'c122' 'UEFA-Super-Cup'
'c569' 'Copa-del-Rey'
'c646' 'Supercopa-de-Espana'
'c882' 'Europa-Conference-League'
  • log_type : I love how many stats are available in the fbref website. These are just awesome for your next project. The log_type could be any of these values:
Log Type
'scores_and_fixtures'
'shooting'
'goalkeeping'
'passing'
'pass_types'
'goal_and_shot_creation'
'defensive_actions'
'possession'
'miscellaneous_stats'

After passing these 4 parameters to the MatchLogsLink object, most of the task is done. Just create a new Data object, and pass the above MatchLogsLink object. An example of this would be :

link = MatchLogsLink('206d90db', '2022-2023', 'c12', 'shooting')
# print(link)  

data = Data(link)

If the link is correct, there shouldn't be a problem. Now, to get the data as a DataFrame object, just call the function fbref2pandas() of the Data object. The functions returns the data as a pandas Dataframe. If the link is incorrect, an exception is raised. Just double check if the data from the table above. Enjoy the data.

To get the data as DataFrame :

df = data.fbref2pandas()

Note : I comply with all the rules given for the data use in the sports reference website, and I believe that it is in fair use. Not many requests will be taken from this package.

Note : Help would be really appreciated to expand this package. Create a PR and add whatever you could scrape from links of FBRef. Great PRs will be merged on small notices.

Metadata

Release files for fbref2pandas 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fbref2pandas 0.0.1
File Size Uploaded Provenance Actions
fbref2pandas-0.0.1.tar.gz 3.6 kB Without provenance Details for fbref2pandas-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fbref2pandas 0.0.1
File Interpreter ABI Platform Actions
fbref2pandas-0.0.1-py3-none-any.whl Python 3 none any Details for fbref2pandas-0.0.1-py3-none-any.whl

Total release size: 8.2 kB

Release files / fbref2pandas-0.0.1.tar.gz

Download URL fbref2pandas-0.0.1.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
03b87c380bfc3ccd30b5b864b10ca1510e5a8bc71dde228b780cae558117b9a6
BLAKE2b-256 checksum
How to use checksums
23633cf8bd6ddf3ca6f6b4b57ea8c33dc2f589fc906db4fc0b83b72a9daea51c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / fbref2pandas-0.0.1-py3-none-any.whl

Download URL fbref2pandas-0.0.1-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f9f23dffe271b244b2de8f4e834dc8c8d69209cc763ccf4c516be2603dc212a
BLAKE2b-256 checksum
How to use checksums
17ab3f512c8c08ff5cbc485bb79a117309c8260ddff4fc34c7c6aba1d0d174bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for fbref2pandas 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page