Skip to main content

Stats and Visualizations for FPL, Fantasy Allsvenskan and Fantasy Eliteserien

Project description

Build Status

Fantasy Premier League variants Stats and Visualization

This project contains a package for collecting captaincy, chip usage, ownership, effective ownership, template team stats from Fantasy Premier League, Fantasy Allsvenskan, and Fantasy Eliteserien.

Installation

To be able to run the package, you have to have Python 3+ installed on your computer.

Check if you have python and pip available. If not you have to install them.

After running the following command, you are ready to go:

pip install fantasy-premier-league-stats

Usage

First, you have to choose one of the games: FPL, ALLSVENSKAN or ELITESERIEN.

To be able to collect stats and create visualizations, you need to get player information and also the teams.

players = api.get_players(game)
team_ids = api.get_league(league_id, max_players, game)
teams = api.get_league_team_picks(team_ids, gameweek, game)

After this, you can get the statistics and plot them if you want (after necessary imports):

chip_usage = chips.get_weekly_chip_usage(teams, percentage=True)
captaincy = captains.get_captaincy_stats(teams, players, percentage=True)
ownership_stats = ownership.get_ownership_stats(teams, players)
effective_ownership_stats = ownership.get_effective_ownership_stats(teams, players)
template = template_team.create_template_team(teams, players, effective=True, percentage=True, with_team=True)

plots.draw_chip_usage(chip_usage)
plots.draw_captaincy_stats(captaincy)
plots.draw_ownership_stats(ownership_stats)
plots.draw_effective_ownership_stats(effective_ownership_stats)
plots.draw_template_team(template, game)

You can either see the plots while running your script or save them to a path of your choice.

Another point is that team picks are cached in path ~/.fpl folder, and if you do not want to download team picks again, you can add overwrite=False to api.get_league_team_picks function call. If you want to clear the directory, you can run clear_directory function in utilities.

Future Improvements and Contributing

I do not plan to enhance the package into containing live stats, but all contributions are welcome. You can create issues for feature requests and bugs. You can also contribute by adding features and creating pull requests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for fantasy-premier-league-stats, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size fantasy_premier_league_stats-0.0.2-py3-none-any.whl (24.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size fantasy-premier-league-stats-0.0.2.tar.gz (18.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page