<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Xpect — football in numbers]]></title><description><![CDATA[Xpect — football in numbers]]></description><link>https://xpectapp.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 24 Nov 2026 12:37:26 GMT</lastBuildDate><atom:link href="https://xpectapp.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Goals minus xG on one weekend: a pandas walkthrough of 42 top-five-league matches (21–22 November 2026)]]></title><description><![CDATA[Expected goals (xG) is easy to quote and easy to misuse. A team "beat its xG", a striker is "running hot". To see what that actually looks like in a real…]]></description><link>https://xpectapp.hashnode.dev/goals-minus-xg-on-one-weekend-a-pandas-walkthrough-of-42-top-five-league-matches-21-22-november-2026</link><guid isPermaLink="true">https://xpectapp.hashnode.dev/goals-minus-xg-on-one-weekend-a-pandas-walkthrough-of-42-top-five-league-matches-21-22-november-2026</guid><category><![CDATA[pandas]]></category><category><![CDATA[Python]]></category><category><![CDATA[data analysis]]></category><dc:creator><![CDATA[Xpect]]></dc:creator><pubDate>Mon, 23 Nov 2026 11:35:03 GMT</pubDate><content:encoded><![CDATA[<p>Expected goals (xG) is easy to quote and easy to misuse. A team "beat its xG", a striker is "running hot". To see what that actually looks like in a real dataset, I took the 42 matches played in the Premier League, La Liga, Serie A, Bundesliga and Ligue 1 on 21–22 November 2026 and computed the simplest possible metric: goals scored minus xG, per team, per match. Then I put that weekend next to the whole 2026/27 season so far.</p>
<h2>The data</h2>
<p>Everything lives in a single SQLite file. Two tables matter here: <code>football_matches</code> (one row per match, with full-time score, shots, shots on target and corners) and <code>football_xg</code> (home and away xG keyed by <code>match_id</code>). The key step is reshaping match rows into team rows, so every match becomes two observations.</p>
<pre><code class="language-python">import sqlite3
import pandas as pd

con = sqlite3.connect("football.db")
df = pd.read_sql("""
    SELECT m.league, m.date, m.home_team, m.away_team,
           m.fthg, m.ftag, x.hxg, x.axg
    FROM football_matches m
    JOIN football_xg x ON x.match_id = m.id
    WHERE m.season = '2627'
      AND m.league IN ('APL','La Liga','Serie A','Bundesliga','Ligue 1')
      AND m.date &lt;= '2026-11-22'
      AND m.fthg IS NOT NULL
""", con)

cols = ["league", "date", "team", "g", "xg", "ga", "xga"]
home = df.rename(columns={"home_team": "team", "fthg": "g", "hxg": "xg",
                          "ftag": "ga", "axg": "xga"})[cols]
away = df.rename(columns={"away_team": "team", "ftag": "g", "axg": "xg",
                          "fthg": "ga", "hxg": "xga"})[cols]
teams = pd.concat([home, away], ignore_index=True)
teams["g_minus_xg"] = teams["g"] - teams["xg"]

weekend = teams[teams["date"].between("2026-11-21", "2026-11-22")]
print(weekend["g"].sum(), weekend["xg"].sum().round(2))
print((weekend["g_minus_xg"] &gt; 0).sum(), (weekend["g_minus_xg"] &lt; 0).sum())
</code></pre>
<h2>Result 1: the weekend finished well below its xG</h2>
<p>The 42 matches produced 127 goals from 153.64 xG. Of the 84 team performances, 28 scored more than their xG and 56 scored less. In other words, the typical side this weekend created more than it converted.</p>
<p>The extremes on each side:</p>
<table>
<thead>
<tr>
<th>Team</th>
<th>Match</th>
<th>Goals</th>
<th>xG</th>
<th>Goals − xG</th>
</tr>
</thead>
<tbody><tr>
<td>Milan</td>
<td>5-1 vs Frosinone</td>
<td>5</td>
<td>2.59</td>
<td>+2.41</td>
</tr>
<tr>
<td>Werder Bremen</td>
<td>4-0 vs Hamburg</td>
<td>4</td>
<td>1.60</td>
<td>+2.40</td>
</tr>
<tr>
<td>Juventus</td>
<td>4-0 vs Venezia</td>
<td>4</td>
<td>1.92</td>
<td>+2.08</td>
</tr>
<tr>
<td>Villarreal</td>
<td>2-3 at Barcelona</td>
<td>2</td>
<td>0.17</td>
<td>+1.83</td>
</tr>
<tr>
<td>Brighton</td>
<td>0-2 at Hull</td>
<td>0</td>
<td>2.26</td>
<td>−2.26</td>
</tr>
<tr>
<td>Hoffenheim</td>
<td>0-1 at Frankfurt</td>
<td>0</td>
<td>2.30</td>
<td>−2.30</td>
</tr>
<tr>
<td>Stuttgart</td>
<td>0-0 at Schalke</td>
<td>0</td>
<td>2.52</td>
<td>−2.52</td>
</tr>
</tbody></table>
<p>Werder Bremen's 4-0 is the cleanest illustration of why a scoreline alone misleads: xG in that match was 1.60 to 1.60.</p>
<h2>Result 2: the season tells the same story, more quietly</h2>
<p>Across 545 top-five-league matches up to 22 November, teams scored 1,641 goals from about 1,785 xG. The ratio of goals to xG is remarkably stable by league:</p>
<table>
<thead>
<tr>
<th>League</th>
<th>Matches</th>
<th>Goals</th>
<th>xG</th>
<th>Goals / xG</th>
</tr>
</thead>
<tbody><tr>
<td>Serie A</td>
<td>119</td>
<td>376</td>
<td>402.7</td>
<td>0.93</td>
</tr>
<tr>
<td>Ligue 1</td>
<td>99</td>
<td>292</td>
<td>316.3</td>
<td>0.92</td>
</tr>
<tr>
<td>Premier League</td>
<td>109</td>
<td>299</td>
<td>324.3</td>
<td>0.92</td>
</tr>
<tr>
<td>La Liga</td>
<td>128</td>
<td>369</td>
<td>405.7</td>
<td>0.91</td>
</tr>
<tr>
<td>Bundesliga</td>
<td>90</td>
<td>305</td>
<td>336.2</td>
<td>0.91</td>
</tr>
</tbody></table>
<p>A ratio below 1.0 in every league suggests the gap is mostly about how this particular xG source is calibrated, not about one league finishing worse than another. That matters: comparing a team's raw goals with raw xG will make almost everyone look like an underperformer. Comparing a team with its own league's ratio is fairer.</p>
<h2>Result 3: who sits at the edges</h2>
<p>Over the season, the largest positive gaps belong to Lazio (28 goals from 21.18 xG), Chelsea (20 from 14.04) and Werder Bremen (21 from 16.01). At the other end: Venezia (8 from 18.16), Nottingham Forest (9 from 17.78) and Villarreal (19 from 27.05).</p>
<p>The defensive mirror (xG against minus goals against) is just as useful. Schalke have conceded 11 goals from 22.91 xG against, Marseille 17 from 25.96 and Stuttgart 15 from 23.86.</p>
<h2>Caveats before you build on this</h2>
<ul>
<li>One weekend is noise. A single deflection moves goals by one and xG by almost nothing.</li>
<li>xG models differ by provider. Never mix sources in the same comparison.</li>
<li>Penalties inflate both goals and xG. Splitting non-penalty xG is the next step if your source provides it.</li>
<li>Team rows double the sample but are not independent: one team's goals are the other team's goals against.</li>
</ul>
<p>If you want the concept itself explained from scratch, there is a <a href="https://tohaprobets.com/futbol/statistika-xg/">Russian-language primer on expected goals by Toha</a>. For how these inputs feed match pages, see <a href="https://xpect.app/predictions/methodology/">the methodology notes behind Xpect's match pages</a>.</p>
<p>Analytics only, 18+</p>
]]></content:encoded></item></channel></rss>