This repo holds the code used in the creation of my short article on ranking Premier League teams based on the fixtures played so far, in the event that the remaining fixtures have to be cancelled.
The main script at rankings/output.py
runs the various ranking methods:
usage: rankings/outputs.py OUTPUT_DIR SUITE [METHOD]
At the time of writing, SUITE
can be:
premier
, for the partial Premier League 19/20 seasonintl
for European international fixtures aggregated from the UEFA Nations 2022 league, 2022 world cup qualifiers, and Euro 2020intl2
for European international fixtures aggregated from the UEFA Nations 2023 league, and the Euro 2024 qualifiers
The code provides the most up-to-date documentation on the outputs produced for each suite.
To set up and run the code:
- Optionally create a Python virtual environment:
python3 -m venv venv
. venv/bin/activate
- Install Python dependencies:
pip install -r requirements.txt
- Run:
# e.g. premier league
mkdir results
python rankings/output.py results premier
The results are contained in CSV files in the data
directory. At the time of
writing, CSVs from football-data.co.uk,
footystats.org and
fixturedownload.com are supported.
To add support for a new CSV format, create a new subclass of CSVProvider
in
rankings/providers.py
with the appropriate CSV header names defined as class
attributes; see the existing classes in that file for examples.
To run the ranking methods on new results data, create a new subclass of
OutputCreator
in rankings/output.py
– see PremierLeagueCovid
and
InternationalLeague
for examples – and extend the main()
function as
appropriate.