Skip to main content

Function: game_corsi_rows()

game_corsi_rows(enrichedPbp, shifts): Row[]

Defined in: src/analytics/hockeytech.ts:1187

Player-level on-ice Corsi/Fenwick joined to time on ice (the body of py <lg>_game_corsi): corsi_fenwick_on_ice(pbp) LEFT-joined to toi_seconds on the string player_id, plus corsi_for_per60 (null unless TOI > 0).

Parameters​

enrichedPbp​

Row[]

Output of enrich_pbp (needs event, team_id, home_team_id, on_ice_home, on_ice_away).

shifts​

Row[]

Shift stints from parse_shifts for the same game.

Returns​

Row[]

The corsi_fenwick_on_ice rows (same order) with toi_seconds (null when the player has no TOI row) and corsi_for_per60 (per60(corsi_for, toi_seconds), null unless toi_seconds > 0). [] when the enriched pbp is empty or lacks the on-ice columns.

Example​

import { game_corsi_rows, parse_shifts } from "sportsdataverse/dist/analytics/hockeytech.js";
const rows = game_corsi_rows(enrichedPbp, parse_shifts(gameshiftsPayload, 42));

Remarks​

The join key is the TOI side's player_id coerced through toInt then String(...); a TOI row with a non-integer id never matches. A player with several TOI rows (same id, different name spelling) is emitted once per match, like a LEFT join.