Skip to main content

Function: helper_nba_team_box()

helper_nba_team_box(final): Row[]

Defined in: src/producers/espn_basketball_box.ts:666

NBA team box (sdv-py helper_nba_team_box, which delegates to the shared wbb_team_box.helper_wbb_team_box; hoopR helper_espn_nba_team_box): one row per team from an ESPN Site v2 summary payload.

Parameters​

final​

any

The ESPN summary payload (final.json) of one game. Reads header.id, header.season.{year,type}, header.competitions[0].{date,competitors} and boxscore.teams[].{team,statistics}.

Returns​

Row[]

Row[] of exactly two rows (team 0 then team 1): the game columns, team_* meta, team_home_away / team_score / team_winner, the stat columns, then opponent_team_*; [] when the payload has no usable boxscore.

Throws​

TypeError when header.competitions[0].date is not a string, or a competitor is null (Python in on None).

Throws​

Error when that date does not parse as %Y-%m-%dT%H:%M[:%S].

Throws​

RangeError when a team id or score is a float inf string.

Example​

const summary = await sdv.nba.espnNbaSummary({ event_id: 401360428 });
const teams = sdv.nba.helper_nba_team_box(summary);
teams.length; // 2

Remarks​

Shared by all four leagues (the others @see this block):

  • The same core runs for every league; there is no per-league column divergence.
  • Stat columns are ordered alphabetically by their ESPN name (R tidyr::spread), with the "M-A" pairs split in place; the column set is the union of both rows (row-1 order first).
  • Returns [] (R's tryCatch skip) when either team's statistics is empty, a team repeats a stat name, winner is absent from BOTH competitors, or a split "M-A" stat is missing for both teams.
  • Each team's competitor is the index-aligned one when the ids match, else the other; an unparseable id on either side leaves team_home_away / team_score / team_winner null.
  • Id columns are decimal strings; the *_pct columns are numbers; the rest of the dtype rules are those of helper_nba_player_box.