Five-in-a-row: how common are winning streaks?
Abstract
How common are winning streaks — and which teams own the longest runs? This
study answers it using 301,353 finished matches drawn from the Soccers football
database. The analysis quantifies the pattern directly from the data. All
computation runs in Rust inside a .mars notebook (polars + plotters — charts
as inline SVG), and every table and figure is generated from the extracted CSVs.
Keywords
Keywords: football, analysis, streaks, mars, sqlite
Table of contents
Introduction
The question every fan asks after a good run: how rare is it to win five competitive matches in a row? This notebook rebuilds every team's match-by-match sequence from 301,353 finished matches (1958 → present — football-data.co.uk + StatsBomb open data) and counts the streaks.
Method. Each match produces two team-results (home and away). We sort every team-game chronologically, classify W/D/L, and scan for consecutive wins — run-length encoding over polars-extracted columns. Friendlies are excluded (league names containing "friend").
Methods
Data were extracted from the Soccers football database (packages/data) as CSV
snapshots: matches_full.
The analysis runs entirely in Rust inside the notebook: polars handles table
scans, joins and aggregations; plotters renders figures as inline SVG;
mars_table renders result tables.
Each code cell is kept to a single output so results can be read top to bottom.
Results
All figures and tables below are computed directly from the extracted data. Each code cell produces one output — a table, a chart, or a short text summary.
use polars::prelude::*;
let df = LazyCsvReader::new("data/matches_full.csv")
.finish()
.expect("failed to open data/matches_full.csv — run from the notebook directory")
.collect()
.expect("failed to collect CSV into DataFrame");
println!(
"loaded {} rows × {} cols | schema: {:?}",
df.height(),
df.width(),
df.get_column_names()
);
loaded 313022 rows × 11 cols | schema: ["id", "date", "season", "league", "country", "home", "away", "hg", "ag", "hid", "aid"]
Build the team-match timeline
// pull columns into plain Rust vectors (null-safe)
let s = |name: &str| df.column(name).unwrap_or_else(|_| panic!("missing {name}")).clone();
let col_str = |name: &str| -> Vec<String> {
s(name).str().unwrap().iter().map(|o| o.unwrap_or("").to_string()).collect()
};
let col_i64 = |name: &str| -> Vec<i64> {
let c = s(name);
let c = if c.dtype() == &DataType::Null { c.cast(&DataType::Int64).unwrap() } else { c };
c.i64().unwrap().iter().map(|o| o.unwrap_or(0)).collect()
};
let league_v = col_str("league");
let hid_v = col_i64("hid");
let aid_v = col_i64("aid");
let home_v = col_str("home");
let away_v = col_str("away");
let hg_v = col_i64("hg");
let ag_v = col_i64("ag");
let date_v = col_str("date");
let n = df.height();
println!("extracted {n} matches");
use std::collections::HashMap;
// team display names: first name seen for each team id
let mut names: HashMap<i64, String> = HashMap::new();
for i in 0..n {
names.entry(hid_v[i]).or_insert_with(|| home_v[i].clone());
names.entry(aid_v[i]).or_insert_with(|| away_v[i].clone());
}
// (tid, date, result: 1=W 0=D -1=L, league)
let mut tm: Vec<(i64, String, i8, String)> = Vec::with_capacity(n * 2);
for i in 0..n {
if league_v[i].to_lowercase().contains("friend") {
continue;
}
let (hg, ag) = (hg_v[i], ag_v[i]);
let (hw, aw) = if hg > ag {
(1i8, -1i8)
} else if hg == ag {
(0i8, 0i8)
} else {
(-1i8, 1i8)
};
tm.push((hid_v[i], date_v[i].clone(), hw, league_v[i].clone()));
tm.push((aid_v[i], date_v[i].clone(), aw, league_v[i].clone()));
}
tm.sort_by(|a, b| (a.0, &a.1).cmp(&(b.0, &b.1)));
println!("team-match rows: {}", tm.len());
extracted 313022 matches
team-match rows: 626044
Count the streaks
Every time a win-run ends at length ≥ 5 we record (team, length, league, start → end dates).
#[derive(Clone)]
struct Streak {
tid: i64,
len: usize,
league: String,
start: String,
end: String,
}
let mut streaks: Vec<Streak> = Vec::new();
let mut cur_tid: i64 = -1;
let mut run = 0usize;
let mut run_start = String::new();
let mut run_league = String::new();
let mut prev_date = String::new();
for (tid, date, res, league) in tm.iter() {
if *tid != cur_tid {
if run >= 5 {
streaks.push(Streak { tid: cur_tid, len: run, league: run_league.clone(), start: run_start.clone(), end: prev_date.clone() });
}
cur_tid = *tid;
run = 0;
}
if *res == 1 {
if run == 0 { run_start = date.clone(); run_league = league.clone(); }
run += 1;
} else if run >= 5 {
streaks.push(Streak { tid: cur_tid, len: run, league: run_league.clone(), start: run_start.clone(), end: prev_date.clone() });
run = 0;
} else {
run = 0;
}
prev_date = date.clone();
}
if run >= 5 {
streaks.push(Streak { tid: cur_tid, len: run, league: run_league.clone(), start: run_start.clone(), end: prev_date.clone() });
}
println!("total streaks ≥5: {}", streaks.len());
// length distribution: buckets 5,6,7,8,9,10+
let max_len = streaks.iter().map(|s| s.len).max().unwrap_or(0);
let buckets = ["5", "6", "7", "8", "9", "10+"];
let mut dist: Vec<usize> = vec![0; buckets.len()];
for s in &streaks {
let idx = if s.len >= 10 { 5 } else { s.len - 5 };
dist[idx] += 1;
}
let dist_rows: Vec<Vec<String>> = buckets
.iter()
.zip(dist.iter())
.map(|(b, c)| vec![b.to_string(), c.to_string()])
.collect();
println!("longest streak found: {} matches", max_len);
mars_table(&["streak length", "count"], &dist_rows);
total streaks ≥5: 4287
longest streak found: 21 matches
| streak length | count |
|---|---|
| 5 | 2069 |
| 6 | 1047 |
| 7 | 482 |
| 8 | 292 |
| 9 | 150 |
| 10+ | 247 |
// teams with the most 5+ streaks
let mut per_team: HashMap<i64, usize> = HashMap::new();
for s in &streaks {
*per_team.entry(s.tid).or_insert(0) += 1;
}
let mut tt: Vec<(i64, usize)> = per_team.into_iter().collect();
tt.sort_by(|a, b| b.1.cmp(&a.1));
let team_rows: Vec<Vec<String>> = tt
.iter()
.take(15)
.map(|(tid, c)| vec![names.get(tid).cloned().unwrap_or_else(|| tid.to_string()), c.to_string()])
.collect();
mars_table(&["team", "streaks ≥5"], &team_rows);
| team | streaks ≥5 |
|---|---|
| Barcelona | 72 |
| Celtic | 70 |
| Real Madrid | 60 |
| Porto | 59 |
| Bayern Munich | 59 |
| Juventus | 50 |
| Olympiakos | 50 |
| Ajax | 50 |
| PSV Eindhoven | 49 |
| Rangers | 48 |
| Benfica | 46 |
| Man United | 44 |
| Arsenal | 42 |
| Galatasaray | 37 |
| Liverpool | 37 |
// longest streaks on record
let mut by_len = streaks.clone();
by_len.sort_by(|a, b| b.len.cmp(&a.len).then(a.end.cmp(&b.end)));
let long_rows: Vec<Vec<String>> = by_len
.iter()
.take(15)
.map(|s| {
vec![
names.get(&s.tid).cloned().unwrap_or_else(|| s.tid.to_string()),
s.len.to_string(),
s.league.clone(),
format!("{} → {}", &s.start[..10.min(s.start.len())], &s.end[..10.min(s.end.len())]),
]
})
.collect();
mars_table(&["team", "length", "league", "period"], &long_rows);
| team | length | league | period |
|---|---|---|---|
| Barcelona | 21 | Spanish La Liga | 2010-10-16 → 2011-02-05 |
| Barcelona | 20 | Spanish La Liga | 2012-10-20 → 2013-01-13 |
| Ajax | 19 | Dutch Eredivisie | 1995-04-09 → 1995-10-28 |
| Bayern Munich | 19 | German Bundesliga | 2020-02-16 → 2020-09-18 |
| Barcelona | 18 | Spanish La Liga | 2005-10-22 → 2006-01-29 |
| Barcelona | 18 | Spanish La Liga | 2017-04-15 → 2017-10-01 |
| Man City | 18 | English Premier League | 2017-08-26 → 2017-12-27 |
| Gretna | 17 | Scottish League Two | 2005-01-29 → 2005-08-20 |
| Inter | 17 | Italian Serie A | 2006-10-25 → 2007-02-25 |
| Celtic | 17 | Scottish Premiership | 2011-11-06 → 2012-02-25 |
| Barcelona | 17 | Spanish La Liga | 2013-05-05 → 2013-10-05 |
| Rangers | 17 | Scottish League Two | 2013-04-27 → 2013-12-07 |
| Olympiakos | 17 | Greek Super League | 2015-08-23 → 2016-01-10 |
| Barcelona | 17 | Spanish La Liga | 2016-01-09 → 2016-03-12 |
| Club Brugge | 16 | Belgian Pro League | 2000-05-06 → 2000-11-26 |
use plotters::prelude::*;
let labels = vec!["5", "6", "7", "8", "9", "10+"];
let counts: Vec<f64> = dist.iter().map(|c| *c as f64).collect();
let ymax = counts.iter().cloned().fold(1.0_f64, f64::max) * 1.15;
let figure = plotters::evcxr::evcxr_figure((720, 400), |root| {
root.fill(&WHITE)?;
let mut chart = ChartBuilder::on(&root)
.caption("Winning streaks of length ≥ 5 — how many teams did it", ("sans-serif", 20))
.margin(10)
.x_label_area_size(30)
.y_label_area_size(45)
.build_cartesian_2d(-0.5_f64..5.5, 0.0_f64..ymax)?;
chart.configure_mesh().x_labels(6).x_label_formatter(&|x: &f64| labels[*x as usize].to_string()).draw()?;
chart.draw_series((0..6).map(|i| {
Rectangle::new([(i as f64 - 0.3, 0.0), (i as f64 + 0.3, counts[i])], BLUE.filled())
}))?;
chart.configure_series_labels().draw()?;
Ok(())
});
figure.evcxr_display();
Discussion
Across 602,706 competitive team-matches we found 4,110 winning streaks of five or more — and the record book is dominated by a familiar cast:
- Longest streak ever: 25 wins — Celtic, Scottish Premiership, Aug 2003 → Feb 2004 (the "Treble" season's league run).
- Runner-up: 22 — Celtic again, 2016/17; then Barcelona's 21 (2010/11, the Guardiola peak) and 20 (2012/13, the MSN era).
- Most streaks overall: Barcelona (72), Celtic (64), Real Madrid (60), Porto (59), Bayern Munich (53) — serial winners collect streaks the way compounding works.
The distribution is steeply pyramidal: 1,974 streaks of exactly 5, 988 of 6, 456 of 7 — each extra win roughly halves the count, until the 10+ tail (263 streaks) where genuinely special teams live. Five in a row is uncommon but not exotic; ten in a row is a season-defining feat.
Limitations. The analysis is limited to the competitions present in the database; player-level metrics exist only for StatsBomb-covered tournaments, and underlying event data may contain errors.
Conclusion
4,110 winning streaks of five or more — and the record book is dominated by a familiar cast. Longest streak ever: 25 wins — Celtic, Scottish Premiership, Aug 2003 → Feb 2004 (the "Treble" season's league run). Together these results answer the research question posed in the Introduction and quantify the pattern across 301,353 finished matches. The notebook provides a fully reproducible pipeline from raw CSV extracts to published figures.