Data Transformation for Premier League xG for teams from 21-22 season
This example demonstrates data transformation for Premier League xG data from the 21-22 season, filtering the dataset to a single team (Arsenal) and computing their maximum accumulated xP and Points values. The visualization uses d3.csvParse to load the CSV, then applies type coercion to convert Matchweek, xP, Points, and xPTable from strings to numbers. Using d3.max, it calculates the season’s peak expected points and actual points for Arsenal, and displays the filtered team data as JSON in a pre element. The data originates from understat.com and is fetched asynchronously through a gist URL.
AI-generated descriptionThis data comes from: https://understat.com/
Transformation: Filtering down to one team so I can make plot of just their season. Also, getting their max xP and Points in the season.
Variables and their types:
Team (categorical): A Premier League Team
Matchweek (quantitative): Which week in the 38 week season the game occured
xP (quantitative): A probability that corresponds to the expected amount of points a team has accumulated so far in the season
Points (quantitative): The number of points gained in the game so far in the season
xPTable (quantitative): The position in the PL table a team would be based on their xP