Skip to content

Making changes for mlb_pbp function#388

Open
spencerlin-ysl wants to merge 6 commits intoBillPetti:development_branchfrom
spencerlin-ysl:fix/mlb-r-pbp-join-error
Open

Making changes for mlb_pbp function#388
spencerlin-ysl wants to merge 6 commits intoBillPetti:development_branchfrom
spencerlin-ysl:fix/mlb-r-pbp-join-error

Conversation

@spencerlin-ysl
Copy link
Copy Markdown

Description

Fixes play-by-play data retrieval for Rookie level games.

Problem

The mlb_pbp() function was failing for most of the Rookie level games because the API returns a different data structure. Specifically:

  • Rookie level games don't have endTime on every pitch

Solution

  • Add conditional logic to detect Rookie level games
  • Use the fact that the playId field has a different structure that encodes the atBatIndex
  • Extract atBatIndex from the playId structure (characters 11-12)
  • Remove overlapping columns before join to prevent conflicts
  • Filter out NA values to prevent warnings

@spencerlin-ysl spencerlin-ysl marked this pull request as ready for review September 30, 2025 22:39
@spencerlin-ysl spencerlin-ysl changed the base branch from development_branch to master September 30, 2025 23:22
@spencerlin-ysl spencerlin-ysl changed the base branch from master to development_branch September 30, 2025 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants