Repository navigation
Bundle maintenance fixes (#499-#504) and fix team_game_logs / date parsing on pandas 3 - #514
Open
yasumorishima wants to merge 16 commits into
Open
yasumorishima wants to merge 16 commits into
yasumorishima wants to merge 16 commits into
Conversation
Replace deprecated chained assignment with direct assignment to avoid FutureWarning in pandas 3.0.
Replace deprecated `Github(token)` with `Github(auth=Auth.Token(token))` to avoid DeprecationWarning from PyGithub.
- Add team.upper() to handle case-insensitive team abbreviations - Add end_season < start_season validation with clear error message
…erence HTML (jldbc#461) Baseball Reference changed their table IDs: - team_batting -> players_standard_batting - team_pitching -> players_standard_pitching Also make header extraction dynamic instead of hardcoded slice indices.
The bundled CSV data ends at 2021 because the upstream Lahman/Retrosheet data hasn't been updated. Since MLB team composition hasn't changed, extrapolate from the last known year when a more recent season is requested.
This was referenced Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This bundles my six open fixes (#499–#504) into one branch so they can be reviewed and merged together, and adds a few fixes I found while re-testing them against pandas 3. Each fix is in its own commit(s), so any of them can be dropped or reverted on its own. I'll close the six originals with a pointer here.
I've left out my docs typo fix (#498) because #491 makes the same change and was opened first.
Closes #467
Closes #459
Closes #455
Closes #462
Closes #461
Closes #486
From the earlier PRs
errors='ignore'inpd.to_numeric/pd.to_datetimewith explicittry/except(repeated warning when running pybaseball.statcast() #467). This one has no new test, but it changes thetest_statcast.pyfixture: the old line discarded its result, so the fixture now really converts the date column.team_results: assign the result of theAttendancereplace instead of the chainedinplace=True, which silently does nothing under copy-on-write (Team Results Future Warning #459). Avoid inplace replace on Attendance Series #509 makes the same change; this version adds a test.retrosheet: useGithub(auth=Auth.Token(...))and fall back to anonymous access when no token is set (retrosheet using deprecated GitHub authentication #455)team_fielding_bref: uppercase the team abbreviation and raiseValueErrorwhenend_season < start_season(team_fielding_bref() can be improved for better parameter formatting and error handling #462)team_batting_bref/team_pitching_bref: read the newplayers_standard_*table IDs and take the headers from the table instead of fixed slices; raise a clear error when the table or its header is missing (team_batting_bref() and team_pitching_bref() not working #461). Bug Fix: Web Tags Update #468 touches the same lines and also updates fielding; I haven't changed fielding here.team_ids: seasons after the bundled data (2021) returned an empty frame; they are now extrapolated from the last year (team_ids method not returning any data for certain years #486)New in this PR
team_game_logson pandas 3 –postprocessstill calledDataFrame.apply(pd.to_numeric, errors="ignore"). pandas 3 removed that option, soteam_game_logs()raisedValueError: invalid error value specified. It now applies a small helper that returns the column unchanged when it can't be converted, which keeps the old behaviour (including tables with duplicate column labels).try_parse_dataframeonly looked at columns whose dtype name isobjectorstring. pandas 3's default string dtype is namedstr, so date columns such as statcast'sgame_datewere returned as text. With fix: replace deprecated errors='ignore' with explicit try/except #499 applied, this is what makestest_try_parse_dataframefail under pandas 3.ATHfrom 2025 on Baseball Reference (/teams/ATH/2025.shtml) and Retrosheet (TEAM2025), and MLB StatsAPI also switches fromOAKtoATHin 2025.teamIDBRandteamIDretronow returnATHfor 2025 and later. I leftteamID/franchID(Lahman) unchanged because I couldn't confirm what Lahman uses for 2025.retrosheetnow importsgithub.Auth(Fix deprecated GitHub authentication in retrosheet.py #501), which first appeared in PyGithub 1.59.0, sosetup.pynow requirespygithub>=1.59instead of>=1.51.Testing
I ran the full
tests/pybaseballsuite on this branch and on master, with pandas 3.0.6 and with pandas 2.2.3 (Python 3.11):statcast_batterfailures are the same on both and are not addressed here.test_statcast_single_game_requesterrored during fixture setup on master; on this branch it gets past the dates and fails comparinghc_x(nanvs<NA>), so pandas 3 support still needs more work after this.The new regression tests fail when run against the source without the fixes and pass with them.
mypyreports no new errors compared with master.