Skip to content

Conversation

@zkornbluth
Copy link

Changes

  • I added stacked as an argument to boxscore(). Adding stacked=True to a call of boxscore() will print a stacked version that fits a narrower window
  • stacked is an optional argument that defaults to False, so existing users of boxscore() are unaffected
  • the original boxscore() function is now boxscore_wide(), which is called with all its arguments from the new boxscore()
  • I also refactored getting gameInfo section into its own function boxscore_gameinfo() as it's the same process for stacked and wide (only width varies)

Fixes #74

Example:

Print the full box score for Yankees @ Astros game on 9/4/2025 (gamePk=776464)

Output

print(statsapi.boxscore(776464, stacked=True))

------------------------------------------------------------------------------- Yankees Batters AB R H RBI BB K LOB AVG OPS ------------------------------------------------------------------------------- 1 Grisham CF 5 2 2 3 0 1 2 .247 .840 2 Rice 1B 4 1 1 0 0 1 0 .245 .816 Goldschmidt 1B 1 0 1 0 0 0 0 .279 .751 3 Judge DH 2 0 0 0 3 0 1 .322 1.105 4 Bellinger RF 5 0 1 1 0 1 1 .278 .833 5 Stanton LF 3 0 0 0 1 1 3 .283 .971 1-Domínguez LF 1 1 0 0 0 0 0 .253 .712 6 Chisholm Jr. 2B 2 0 0 0 0 1 0 .242 .838 Caballero 2B 2 0 0 1 1 1 1 .230 .666 7 Wells, A C 2 2 0 0 2 1 3 .215 .719 8 Volpe SS 4 0 1 0 0 1 2 .208 .668 9 McMahon 3B 4 2 3 3 0 0 0 .223 .721 ------------------------------------------------------------------------------- Totals 35 8 9 8 7 8 13 ------------------------------------------------------------------------------- 1-Ran for Stanton in the 8th. BATTING HR: McMahon (19, 5th inning off Javier, 0 on, 1 out); Grisham (30, 8th inning off Ort, 2 on, 2 out). TB: Bellinger; Goldschmidt; Grisham 5; McMahon 6; Rice; Volpe. RBI: Bellinger (87); Caballero (33); Grisham 3 (64); McMahon 3 (50). 2-out RBI: Grisham 3; McMahon 2; Caballero. Runners left in scoring position, 2 out: Bellinger; Wells, A 2; Grisham. Team RISP: 4-for-9. Team LOB: 7. FIELDING E: Rice (5, missed catch); McMahon (9, fielding); Caballero (10, throw). ------------------------------------------------------------------------------- Astros Batters AB R H RBI BB K LOB AVG OPS ------------------------------------------------------------------------------- 1 Peña SS 5 0 1 0 0 1 2 .305 .843 2 Alvarez, Y LF 5 2 4 2 0 0 0 .273 .811 3 Altuve DH 3 0 0 0 2 2 3 .269 .783 4 Correa 3B 5 0 2 0 0 1 4 .274 .718 5 Walker, C 1B 5 0 0 0 0 3 6 .233 .700 6 Diaz, Ya C 3 0 0 0 1 1 3 .251 .694 7 Smith RF 2 0 0 0 0 0 3 .242 .671 a-Sánchez, J RF 2 1 1 1 0 0 1 .255 .743 8 Urías, R 2B 3 0 0 0 0 1 2 .250 .692 c-Caratini PH 1 1 1 0 0 0 0 .268 .743 9 Dubón CF 2 0 0 0 0 0 0 .249 .668 b-Trammell CF 2 0 1 0 0 1 0 .208 .670 ------------------------------------------------------------------------------- Totals 38 4 10 3 3 10 24 ------------------------------------------------------------------------------- a-Homered for Smith in the 7th. b-Struck out for Dubón in the 7th. c-Singled for Urías, R in the 9th. BATTING 2B: Correa (24, Rodón); Alvarez, Y (6, Rodón); Trammell (6, Bednar). HR: Alvarez, Y (5, 3rd inning off Rodón, 0 on, 2 out); Sánchez, J (13, 7th inning off Weaver, 0 on, 0 out). TB: Alvarez, Y 8; Caratini; Correa 3; Peña; Sánchez, J 4; Trammell 2. RBI: Alvarez, Y 2 (25); Sánchez, J (43). 2-out RBI: Alvarez, Y. Runners left in scoring position, 2 out: Urías, R; Walker, C 2; Altuve. Team RISP: 1-for-11. Team LOB: 10. ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- Yankees Pitchers IP H R ER BB K HR ERA ------------------------------------------------------------------------------- Rodón (W, 16-7) 6.0 3 2 1 2 3 1 3.12 Weaver (H, 17) 0.2 3 1 1 0 2 1 2.84 Cruz, F (H, 13) 1.1 1 0 0 0 3 0 2.72 Bednar 1.0 3 1 1 1 2 0 2.58 ------------------------------------------------------------------------------- Totals 9.0 10 4 3 3 10 2 ------------------------------------------------------------------------------- Astros Pitchers IP H R ER BB K HR ERA ------------------------------------------------------------------------------- Javier (L, 1-2) 4.1 6 4 4 3 4 1 4.43 De Los Santos, E 1.2 0 0 0 1 1 0 3.72 Kimbrel 1.0 0 0 0 1 1 0 0.00 Ort 0.2 3 4 4 2 1 1 4.89 Murray 1.1 0 0 0 0 1 0 0.00 ------------------------------------------------------------------------------- Totals 9.0 9 8 8 7 8 2 ------------------------------------------------------------------------------- WP: Javier. Pitch timer violations: Javier (pitcher); De Los Santos, E 3 (pitcher 3). Pitches-strikes: Rodón 109-69; Weaver 18-12; Cruz, F 18-12; Bednar 33-20; Javier 78-46; De Los Santos, E 24-17; Kimbrel 13-7; Ort 27-16; Murray 14-12. Groundouts-flyouts: Rodón 9-2; Weaver 0-0; Cruz, F 0-1; Bednar 0-0; Javier 3-1; De Los Santos, E 2-1; Kimbrel 0-1; Ort 0-0; Murray 0-2. Batters faced: Rodón 24; Weaver 5; Cruz, F 5; Bednar 7; Javier 22; De Los Santos, E 6; Kimbrel 3; Ort 7; Murray 4. Inherited runners-scored: Cruz, F 2-0; De Los Santos, E 3-1; Murray 1-0. Umpires: HP: Adrian Johnson. 1B: Paul Clemons. 2B: Ramon De Jesus. 3B: Brian Walsh. Weather: 73 degrees, Roof Closed. Wind: 0 mph, None. First pitch: 6:41 PM. T: 3:24. Att: 35,018. Venue: Daikin Park. September 4, 2025 ------------------------------------------------------------------------------- 
- Now can add stacked=True to a call of boxscore() to get a version that fits a narrower window - stacked is an optional argument that defaults to False, so existing users of boxscore() are unaffected - also refactored getting gameInfo section into its own function boxscore_gameinfo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant