vaastav / Fantasy-Premier-League

Creates a .csv file of all players in the English Player League with their respective team and total fantasy points
Other
1.47k stars 816 forks source link
fantasy-premier-league fpl fpl-analysis python

GitSpo Mentions paypal

Fantasy-Premier-League

ARCHIVAL NOTICE

This repository will be archived at the end of the 2024-25 season. NO updates will be posted to this repository after the 2024-25 season.

Description

A FPL library that gets all the basic stats for each player, gw-specific data for each player and season history of each player

How to CIte this dataset?

BibTeX:

@misc{anand2016fantasypremierleague,
  title = {{FPL Historical Dataset}},
  author = {Anand, Vaastav},
  year = {2022},
  howpublished = {Retrieved August 2022 from \url{https://github.com/vaastav/Fantasy-Premier-League/}}
}

Acknowledgement

FAQ

Data Structure

The data folder contains the data from past seasons as well as the current season. It is structured as follows:

Accessing the Data Directly in Python

You can access data files within this repository programmatically using Python and the pandas library. Below is an example using the data/2023-24/gws/merged_gw.csv file. Similar methods can be applied to other data files in the repository. Note this is using the raw URL for direct file access, bypassing the GitHub UI.

import pandas as pd

# URL of the CSV file (example)
url = "https://raw.githubusercontent.com/vaastav/Fantasy-Premier-League/master/data/2023-24/gws/merged_gw.csv"

# Read the CSV file into a pandas DataFrame
df = pd.read_csv(url)

Player Position Data

In players_raw.csv, element_type is the field that corresponds to the position. 1 = GK 2 = DEF 3 = MID 4 = FWD

Errata

Contributing

Using

If you use data from here for your website or blog posts, then I would humbly request that you please add a link back to this repo as the data source (and I would in turn add a link to your post/site as a notable usage of this repo).

Downloading Your Team Data

You can download the data for your team by executing the following steps:

python teams_scraper.py <team_id>
#Eg: python teams_scraper.py 4582

This will create a new folder called "team__data18-19" with individual files of all the important data

Notable Usages of this Repository