Overview
TheRankingTable class provides methods to retrieve, process, and output ranking data for the Top 5 European Leagues (Premier League, La Liga, Serie A, Ligue 1, Bundesliga) in various formats.
Constructor
RankingTable
The league to scrape data for. Supported leagues:
- “Premier League”
- “La Liga”
- “Serie A”
- “Ligue 1”
- “Bundesliga”
The specific season to scrape data for (e.g., “2023-2024”). If not provided, the current season is used
Whether to cache scraped data
Example
Methods
get_ranking_list
The processed ranking data as a list of lists. Each inner list represents a team’s ranking data
Example
get_ranking_csv
The name of the file to save the data to (without extension)
The header to include in the CSV file
This method doesn’t return a value. It creates a CSV file
Example
get_ranking_json
The name of the file to save the data to (without extension)
The header to include in the JSON file
This method doesn’t return a value. It creates a JSON file
Example
get_ranking_dict
The header to include in the dictionary (parent key for the entire data)
The processed ranking data as a dictionary
Example
get_ranking_pdf
premier_league[pdf] to be installed.
This method creates a formatted PDF file with the ranking table, including color-coded rows for European qualification spots and relegation.
The name of the file to save the PDF to (without extension)
The directory to save the PDF file to
This method doesn’t return a value. It creates a PDF file
PDF Color Coding
The PDF table uses color coding to indicate:- Light Green: Champions League qualification
- Medium Green: Europa League qualification
- Dark Green: Europa Conference League qualification
- Red: Relegation zone
Example
find_season_limit
The earliest year with data for the league:
- Premier League: 1947
- La Liga: 1929
- Serie A: 1929
- Ligue 1: 1945
- Bundesliga: 1963
Example
Attributes
league
season
ranking_list
European Qualification Logic
For Premier League seasons from 2021 onwards, the class automatically determines European qualification spots based on:- Champions League winners: Automatic Champions League spot
- Europa League winners: Automatic Champions League spot
- Europa Conference League winners: Automatic Europa League spot
- FA Cup winners: Europa League spot (or next available if already qualified)
- EFL Cup winners: Europa Conference League spot (or next available if already qualified)
- League position: Top 4 get Champions League, positions 5-6 get Europa League/Conference League based on cup results
Season Format
All seasons must be specified in the format “YYYY-YYYY” where:- The first year is the start of the season
- The second year is the end of the season
- Example: “2023-2024” represents the 2023/24 season
Dependencies
Optional Dependencies
To use the PDF export functionality, install the package with PDF support:reportlab library required for PDF generation.