brlib 0.0.2__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {brlib-0.0.2 → brlib-0.2.0}/.github/workflows/test.yml +6 -4
- {brlib-0.0.2 → brlib-0.2.0}/PKG-INFO +11 -7
- {brlib-0.0.2 → brlib-0.2.0}/README.md +9 -5
- {brlib-0.0.2 → brlib-0.2.0}/pyproject.toml +1 -1
- brlib-0.2.0/src/brlib/__init__.py +33 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/_helpers/abbreviations_manager.py +2 -3
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/_helpers/constants.py +60 -50
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/_helpers/no_hitter_dicts.py +16 -8
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/_helpers/utils.py +16 -11
- brlib-0.2.0/src/brlib/all_major_leaguers.py +72 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/find_asg.py +32 -5
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/find_games.py +66 -13
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/find_teams.py +45 -6
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/game.py +326 -91
- brlib-0.0.2/src/brlib/games.py → brlib-0.2.0/src/brlib/game_set.py +222 -47
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/get_games.py +30 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/get_players.py +30 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/get_teams.py +30 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/options.py +246 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/player.py +264 -97
- brlib-0.2.0/src/brlib/player_set.py +227 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/team.py +260 -75
- brlib-0.2.0/src/brlib/team_set.py +313 -0
- {brlib-0.0.2/tests/abbreviations_manager → brlib-0.2.0/tests}/_helpers/test_abbreviations_manager.py +22 -6
- brlib-0.2.0/tests/_helpers/test_no_hitter_dicts.py +100 -0
- brlib-0.2.0/tests/_helpers/test_utils.py +58 -0
- brlib-0.2.0/tests/conftest.py +138 -0
- brlib-0.2.0/tests/expected/games/original/1961-allstar-game-1/batting.csv +46 -0
- brlib-0.2.0/tests/expected/games/original/1961-allstar-game-1/fielding.csv +41 -0
- brlib-0.2.0/tests/expected/games/original/1961-allstar-game-1/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/1961-allstar-game-1/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/1961-allstar-game-1/pitching.csv +15 -0
- brlib-0.2.0/tests/expected/games/original/1961-allstar-game-1/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/1961-allstar-game-1/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/1961-allstar-game-1/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/1961-allstar-game-1/ump_info.csv +7 -0
- brlib-0.2.0/tests/expected/games/original/2025-allstar-game/batting.csv +42 -0
- brlib-0.2.0/tests/expected/games/original/2025-allstar-game/fielding.csv +60 -0
- brlib-0.2.0/tests/expected/games/original/2025-allstar-game/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/2025-allstar-game/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/2025-allstar-game/pitching.csv +27 -0
- brlib-0.2.0/tests/expected/games/original/2025-allstar-game/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/2025-allstar-game/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/2025-allstar-game/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/2025-allstar-game/ump_info.csv +7 -0
- brlib-0.2.0/tests/expected/games/original/ANA202305090/batting.csv +24 -0
- brlib-0.2.0/tests/expected/games/original/ANA202305090/fielding.csv +25 -0
- brlib-0.2.0/tests/expected/games/original/ANA202305090/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/ANA202305090/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/ANA202305090/pitching.csv +7 -0
- brlib-0.2.0/tests/expected/games/original/ANA202305090/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/ANA202305090/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/ANA202305090/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/ANA202305090/ump_info.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/BOS201708250/batting.csv +27 -0
- brlib-0.2.0/tests/expected/games/original/BOS201708250/fielding.csv +32 -0
- brlib-0.2.0/tests/expected/games/original/BOS201708250/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/BOS201708250/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/BOS201708250/pitching.csv +11 -0
- brlib-0.2.0/tests/expected/games/original/BOS201708250/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/BOS201708250/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/BOS201708250/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/BOS201708250/ump_info.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/FLO199407290/batting.csv +36 -0
- brlib-0.2.0/tests/expected/games/original/FLO199407290/fielding.csv +32 -0
- brlib-0.2.0/tests/expected/games/original/FLO199407290/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/FLO199407290/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/FLO199407290/pitching.csv +12 -0
- brlib-0.2.0/tests/expected/games/original/FLO199407290/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/FLO199407290/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/FLO199407290/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/FLO199407290/ump_info.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/MLA190105301/batting.csv +21 -0
- brlib-0.2.0/tests/expected/games/original/MLA190105301/fielding.csv +21 -0
- brlib-0.2.0/tests/expected/games/original/MLA190105301/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/MLA190105301/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/MLA190105301/pitching.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/MLA190105301/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/MLA190105301/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/MLA190105301/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/MLA190105301/ump_info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/NYN200908230/batting.csv +31 -0
- brlib-0.2.0/tests/expected/games/original/NYN200908230/fielding.csv +28 -0
- brlib-0.2.0/tests/expected/games/original/NYN200908230/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/NYN200908230/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/NYN200908230/pitching.csv +12 -0
- brlib-0.2.0/tests/expected/games/original/NYN200908230/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/NYN200908230/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/NYN200908230/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/NYN200908230/ump_info.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/PHI202211020/batting.csv +22 -0
- brlib-0.2.0/tests/expected/games/original/PHI202211020/fielding.csv +30 -0
- brlib-0.2.0/tests/expected/games/original/PHI202211020/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/PHI202211020/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/PHI202211020/pitching.csv +13 -0
- brlib-0.2.0/tests/expected/games/original/PHI202211020/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/PHI202211020/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/PHI202211020/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/PHI202211020/ump_info.csv +7 -0
- brlib-0.2.0/tests/expected/games/original/PIT192010023/batting.csv +22 -0
- brlib-0.2.0/tests/expected/games/original/PIT192010023/fielding.csv +22 -0
- brlib-0.2.0/tests/expected/games/original/PIT192010023/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/PIT192010023/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/PIT192010023/pitching.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/PIT192010023/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/PIT192010023/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/PIT192010023/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/PIT192010023/ump_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA197805231/batting.csv +24 -0
- brlib-0.2.0/tests/expected/games/original/SEA197805231/fielding.csv +24 -0
- brlib-0.2.0/tests/expected/games/original/SEA197805231/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/SEA197805231/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA197805231/pitching.csv +6 -0
- brlib-0.2.0/tests/expected/games/original/SEA197805231/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SEA197805231/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA197805231/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SEA197805231/ump_info.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/SEA201208150/batting.csv +23 -0
- brlib-0.2.0/tests/expected/games/original/SEA201208150/fielding.csv +22 -0
- brlib-0.2.0/tests/expected/games/original/SEA201208150/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/SEA201208150/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA201208150/pitching.csv +6 -0
- brlib-0.2.0/tests/expected/games/original/SEA201208150/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SEA201208150/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA201208150/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SEA201208150/ump_info.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/SEA201804190/batting.csv +24 -0
- brlib-0.2.0/tests/expected/games/original/SEA201804190/fielding.csv +30 -0
- brlib-0.2.0/tests/expected/games/original/SEA201804190/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/SEA201804190/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA201804190/pitching.csv +11 -0
- brlib-0.2.0/tests/expected/games/original/SEA201804190/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SEA201804190/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA201804190/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SEA201804190/ump_info.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/SEA201905270/batting.csv +21 -0
- brlib-0.2.0/tests/expected/games/original/SEA201905270/fielding.csv +27 -0
- brlib-0.2.0/tests/expected/games/original/SEA201905270/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/SEA201905270/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA201905270/pitching.csv +11 -0
- brlib-0.2.0/tests/expected/games/original/SEA201905270/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SEA201905270/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA201905270/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SEA201905270/ump_info.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/SEA202210150/batting.csv +26 -0
- brlib-0.2.0/tests/expected/games/original/SEA202210150/fielding.csv +40 -0
- brlib-0.2.0/tests/expected/games/original/SEA202210150/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/SEA202210150/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA202210150/pitching.csv +21 -0
- brlib-0.2.0/tests/expected/games/original/SEA202210150/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SEA202210150/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SEA202210150/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SEA202210150/ump_info.csv +7 -0
- brlib-0.2.0/tests/expected/games/original/SLN190710051/batting.csv +22 -0
- brlib-0.2.0/tests/expected/games/original/SLN190710051/fielding.csv +22 -0
- brlib-0.2.0/tests/expected/games/original/SLN190710051/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/original/SLN190710051/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SLN190710051/pitching.csv +5 -0
- brlib-0.2.0/tests/expected/games/original/SLN190710051/players.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SLN190710051/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/original/SLN190710051/teams.json +1 -0
- brlib-0.2.0/tests/expected/games/original/SLN190710051/ump_info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/1961-allstar-game-1/batting.csv +46 -0
- brlib-0.2.0/tests/expected/games/updated/1961-allstar-game-1/fielding.csv +41 -0
- brlib-0.2.0/tests/expected/games/updated/1961-allstar-game-1/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/1961-allstar-game-1/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/1961-allstar-game-1/pitching.csv +15 -0
- brlib-0.2.0/tests/expected/games/updated/1961-allstar-game-1/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/2025-allstar-game/batting.csv +42 -0
- brlib-0.2.0/tests/expected/games/updated/2025-allstar-game/fielding.csv +60 -0
- brlib-0.2.0/tests/expected/games/updated/2025-allstar-game/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/2025-allstar-game/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/2025-allstar-game/pitching.csv +27 -0
- brlib-0.2.0/tests/expected/games/updated/2025-allstar-game/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/ANA202305090/batting.csv +24 -0
- brlib-0.2.0/tests/expected/games/updated/ANA202305090/fielding.csv +25 -0
- brlib-0.2.0/tests/expected/games/updated/ANA202305090/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/ANA202305090/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/ANA202305090/pitching.csv +7 -0
- brlib-0.2.0/tests/expected/games/updated/ANA202305090/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/BOS201708250/batting.csv +27 -0
- brlib-0.2.0/tests/expected/games/updated/BOS201708250/fielding.csv +32 -0
- brlib-0.2.0/tests/expected/games/updated/BOS201708250/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/BOS201708250/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/BOS201708250/pitching.csv +11 -0
- brlib-0.2.0/tests/expected/games/updated/BOS201708250/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/FLO199407290/batting.csv +36 -0
- brlib-0.2.0/tests/expected/games/updated/FLO199407290/fielding.csv +32 -0
- brlib-0.2.0/tests/expected/games/updated/FLO199407290/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/FLO199407290/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/FLO199407290/pitching.csv +12 -0
- brlib-0.2.0/tests/expected/games/updated/FLO199407290/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/MLA190105301/batting.csv +21 -0
- brlib-0.2.0/tests/expected/games/updated/MLA190105301/fielding.csv +21 -0
- brlib-0.2.0/tests/expected/games/updated/MLA190105301/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/MLA190105301/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/MLA190105301/pitching.csv +5 -0
- brlib-0.2.0/tests/expected/games/updated/MLA190105301/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/NYN200908230/batting.csv +31 -0
- brlib-0.2.0/tests/expected/games/updated/NYN200908230/fielding.csv +28 -0
- brlib-0.2.0/tests/expected/games/updated/NYN200908230/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/NYN200908230/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/NYN200908230/pitching.csv +12 -0
- brlib-0.2.0/tests/expected/games/updated/NYN200908230/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/PHI202211020/batting.csv +22 -0
- brlib-0.2.0/tests/expected/games/updated/PHI202211020/fielding.csv +30 -0
- brlib-0.2.0/tests/expected/games/updated/PHI202211020/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/PHI202211020/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/PHI202211020/pitching.csv +13 -0
- brlib-0.2.0/tests/expected/games/updated/PHI202211020/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/PIT192010023/batting.csv +22 -0
- brlib-0.2.0/tests/expected/games/updated/PIT192010023/fielding.csv +22 -0
- brlib-0.2.0/tests/expected/games/updated/PIT192010023/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/PIT192010023/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/PIT192010023/pitching.csv +5 -0
- brlib-0.2.0/tests/expected/games/updated/PIT192010023/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SEA197805231/batting.csv +24 -0
- brlib-0.2.0/tests/expected/games/updated/SEA197805231/fielding.csv +24 -0
- brlib-0.2.0/tests/expected/games/updated/SEA197805231/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/SEA197805231/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SEA197805231/pitching.csv +6 -0
- brlib-0.2.0/tests/expected/games/updated/SEA197805231/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201208150/batting.csv +23 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201208150/fielding.csv +22 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201208150/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201208150/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201208150/pitching.csv +6 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201208150/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201804190/batting.csv +24 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201804190/fielding.csv +30 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201804190/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201804190/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201804190/pitching.csv +11 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201804190/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201905270/batting.csv +21 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201905270/fielding.csv +27 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201905270/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201905270/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201905270/pitching.csv +11 -0
- brlib-0.2.0/tests/expected/games/updated/SEA201905270/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SEA202210150/batting.csv +26 -0
- brlib-0.2.0/tests/expected/games/updated/SEA202210150/fielding.csv +40 -0
- brlib-0.2.0/tests/expected/games/updated/SEA202210150/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/SEA202210150/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SEA202210150/pitching.csv +21 -0
- brlib-0.2.0/tests/expected/games/updated/SEA202210150/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SLN190710051/batting.csv +22 -0
- brlib-0.2.0/tests/expected/games/updated/SLN190710051/fielding.csv +22 -0
- brlib-0.2.0/tests/expected/games/updated/SLN190710051/info.csv +2 -0
- brlib-0.2.0/tests/expected/games/updated/SLN190710051/linescore.csv +3 -0
- brlib-0.2.0/tests/expected/games/updated/SLN190710051/pitching.csv +5 -0
- brlib-0.2.0/tests/expected/games/updated/SLN190710051/team_info.csv +3 -0
- brlib-0.2.0/tests/expected/players/original/aloumo01/batting.csv +40 -0
- brlib-0.2.0/tests/expected/players/original/aloumo01/bling.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/aloumo01/fielding.csv +80 -0
- brlib-0.2.0/tests/expected/players/original/aloumo01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/aloumo01/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/players/original/aloumo01/relatives.json +1 -0
- brlib-0.2.0/tests/expected/players/original/aloumo01/teams.json +1 -0
- brlib-0.2.0/tests/expected/players/original/bendech01/batting.csv +33 -0
- brlib-0.2.0/tests/expected/players/original/bendech01/bling.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/bendech01/fielding.csv +43 -0
- brlib-0.2.0/tests/expected/players/original/bendech01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/bendech01/pitching.csv +33 -0
- brlib-0.2.0/tests/expected/players/original/bendech01/relatives.json +1 -0
- brlib-0.2.0/tests/expected/players/original/bendech01/teams.json +1 -0
- brlib-0.2.0/tests/expected/players/original/colli05/batting.csv +4 -0
- brlib-0.2.0/tests/expected/players/original/colli05/bling.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/colli05/fielding.csv +3 -0
- brlib-0.2.0/tests/expected/players/original/colli05/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/colli05/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/players/original/colli05/relatives.json +1 -0
- brlib-0.2.0/tests/expected/players/original/colli05/teams.json +1 -0
- brlib-0.2.0/tests/expected/players/original/gibsojo99/batting.csv +34 -0
- brlib-0.2.0/tests/expected/players/original/gibsojo99/bling.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/gibsojo99/fielding.csv +66 -0
- brlib-0.2.0/tests/expected/players/original/gibsojo99/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/gibsojo99/pitching.csv +4 -0
- brlib-0.2.0/tests/expected/players/original/gibsojo99/relatives.json +1 -0
- brlib-0.2.0/tests/expected/players/original/gibsojo99/teams.json +1 -0
- brlib-0.2.0/tests/expected/players/original/hallaro01/batting.csv +25 -0
- brlib-0.2.0/tests/expected/players/original/hallaro01/bling.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/hallaro01/fielding.csv +21 -0
- brlib-0.2.0/tests/expected/players/original/hallaro01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/hallaro01/pitching.csv +27 -0
- brlib-0.2.0/tests/expected/players/original/hallaro01/relatives.json +1 -0
- brlib-0.2.0/tests/expected/players/original/hallaro01/teams.json +1 -0
- brlib-0.2.0/tests/expected/players/original/jacksre01/batting.csv +46 -0
- brlib-0.2.0/tests/expected/players/original/jacksre01/bling.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/jacksre01/fielding.csv +94 -0
- brlib-0.2.0/tests/expected/players/original/jacksre01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/jacksre01/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/players/original/jacksre01/relatives.json +1 -0
- brlib-0.2.0/tests/expected/players/original/jacksre01/teams.json +1 -0
- brlib-0.2.0/tests/expected/players/original/kigerma01/batting.csv +4 -0
- brlib-0.2.0/tests/expected/players/original/kigerma01/bling.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/kigerma01/fielding.csv +1 -0
- brlib-0.2.0/tests/expected/players/original/kigerma01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/kigerma01/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/players/original/kigerma01/relatives.json +1 -0
- brlib-0.2.0/tests/expected/players/original/kigerma01/teams.json +1 -0
- brlib-0.2.0/tests/expected/players/original/pressry01/batting.csv +27 -0
- brlib-0.2.0/tests/expected/players/original/pressry01/bling.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/pressry01/fielding.csv +25 -0
- brlib-0.2.0/tests/expected/players/original/pressry01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/pressry01/pitching.csv +34 -0
- brlib-0.2.0/tests/expected/players/original/pressry01/relatives.json +1 -0
- brlib-0.2.0/tests/expected/players/original/pressry01/teams.json +1 -0
- brlib-0.2.0/tests/expected/players/original/vogtst01/batting.csv +29 -0
- brlib-0.2.0/tests/expected/players/original/vogtst01/bling.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/vogtst01/fielding.csv +52 -0
- brlib-0.2.0/tests/expected/players/original/vogtst01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/original/vogtst01/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/players/original/vogtst01/relatives.json +1 -0
- brlib-0.2.0/tests/expected/players/original/vogtst01/teams.json +1 -0
- brlib-0.2.0/tests/expected/players/updated/aloumo01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/updated/aloumo01/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/players/updated/bendech01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/updated/bendech01/pitching.csv +33 -0
- brlib-0.2.0/tests/expected/players/updated/colli05/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/updated/colli05/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/players/updated/gibsojo99/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/updated/gibsojo99/pitching.csv +4 -0
- brlib-0.2.0/tests/expected/players/updated/hallaro01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/updated/hallaro01/pitching.csv +27 -0
- brlib-0.2.0/tests/expected/players/updated/jacksre01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/updated/jacksre01/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/players/updated/kigerma01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/updated/kigerma01/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/players/updated/pressry01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/updated/pressry01/pitching.csv +34 -0
- brlib-0.2.0/tests/expected/players/updated/vogtst01/info.csv +2 -0
- brlib-0.2.0/tests/expected/players/updated/vogtst01/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/teams/original/BBB1924/batting.csv +26 -0
- brlib-0.2.0/tests/expected/teams/original/BBB1924/fielding.csv +22 -0
- brlib-0.2.0/tests/expected/teams/original/BBB1924/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/original/BBB1924/pitching.csv +10 -0
- brlib-0.2.0/tests/expected/teams/original/BBB1924/players.json +1 -0
- brlib-0.2.0/tests/expected/teams/original/BEG1939/batting.csv +45 -0
- brlib-0.2.0/tests/expected/teams/original/BEG1939/fielding.csv +37 -0
- brlib-0.2.0/tests/expected/teams/original/BEG1939/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/original/BEG1939/pitching.csv +17 -0
- brlib-0.2.0/tests/expected/teams/original/BEG1939/players.json +1 -0
- brlib-0.2.0/tests/expected/teams/original/CHC2020/batting.csv +49 -0
- brlib-0.2.0/tests/expected/teams/original/CHC2020/fielding.csv +69 -0
- brlib-0.2.0/tests/expected/teams/original/CHC2020/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/original/CHC2020/pitching.csv +36 -0
- brlib-0.2.0/tests/expected/teams/original/CHC2020/players.json +1 -0
- brlib-0.2.0/tests/expected/teams/original/COT1932/batting.csv +1 -0
- brlib-0.2.0/tests/expected/teams/original/COT1932/fielding.csv +1 -0
- brlib-0.2.0/tests/expected/teams/original/COT1932/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/original/COT1932/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/teams/original/COT1932/players.json +1 -0
- brlib-0.2.0/tests/expected/teams/original/HOU2022/batting.csv +52 -0
- brlib-0.2.0/tests/expected/teams/original/HOU2022/fielding.csv +75 -0
- brlib-0.2.0/tests/expected/teams/original/HOU2022/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/original/HOU2022/pitching.csv +37 -0
- brlib-0.2.0/tests/expected/teams/original/HOU2022/players.json +1 -0
- brlib-0.2.0/tests/expected/teams/original/LAA2012/batting.csv +39 -0
- brlib-0.2.0/tests/expected/teams/original/LAA2012/fielding.csv +45 -0
- brlib-0.2.0/tests/expected/teams/original/LAA2012/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/original/LAA2012/pitching.csv +25 -0
- brlib-0.2.0/tests/expected/teams/original/LAA2012/players.json +1 -0
- brlib-0.2.0/tests/expected/teams/original/SEA2012/batting.csv +38 -0
- brlib-0.2.0/tests/expected/teams/original/SEA2012/fielding.csv +39 -0
- brlib-0.2.0/tests/expected/teams/original/SEA2012/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/original/SEA2012/pitching.csv +20 -0
- brlib-0.2.0/tests/expected/teams/original/SEA2012/players.json +1 -0
- brlib-0.2.0/tests/expected/teams/original/WSH1904/batting.csv +31 -0
- brlib-0.2.0/tests/expected/teams/original/WSH1904/fielding.csv +29 -0
- brlib-0.2.0/tests/expected/teams/original/WSH1904/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/original/WSH1904/pitching.csv +11 -0
- brlib-0.2.0/tests/expected/teams/original/WSH1904/players.json +1 -0
- brlib-0.2.0/tests/expected/teams/updated/BBB1924/batting.csv +26 -0
- brlib-0.2.0/tests/expected/teams/updated/BBB1924/fielding.csv +22 -0
- brlib-0.2.0/tests/expected/teams/updated/BBB1924/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/updated/BBB1924/pitching.csv +10 -0
- brlib-0.2.0/tests/expected/teams/updated/BEG1939/batting.csv +45 -0
- brlib-0.2.0/tests/expected/teams/updated/BEG1939/fielding.csv +37 -0
- brlib-0.2.0/tests/expected/teams/updated/BEG1939/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/updated/BEG1939/pitching.csv +17 -0
- brlib-0.2.0/tests/expected/teams/updated/CHC2020/batting.csv +49 -0
- brlib-0.2.0/tests/expected/teams/updated/CHC2020/fielding.csv +69 -0
- brlib-0.2.0/tests/expected/teams/updated/CHC2020/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/updated/CHC2020/pitching.csv +36 -0
- brlib-0.2.0/tests/expected/teams/updated/COT1932/batting.csv +1 -0
- brlib-0.2.0/tests/expected/teams/updated/COT1932/fielding.csv +1 -0
- brlib-0.2.0/tests/expected/teams/updated/COT1932/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/updated/COT1932/pitching.csv +1 -0
- brlib-0.2.0/tests/expected/teams/updated/HOU2022/batting.csv +52 -0
- brlib-0.2.0/tests/expected/teams/updated/HOU2022/fielding.csv +75 -0
- brlib-0.2.0/tests/expected/teams/updated/HOU2022/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/updated/HOU2022/pitching.csv +37 -0
- brlib-0.2.0/tests/expected/teams/updated/LAA2012/batting.csv +39 -0
- brlib-0.2.0/tests/expected/teams/updated/LAA2012/fielding.csv +45 -0
- brlib-0.2.0/tests/expected/teams/updated/LAA2012/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/updated/LAA2012/pitching.csv +25 -0
- brlib-0.2.0/tests/expected/teams/updated/SEA2012/batting.csv +38 -0
- brlib-0.2.0/tests/expected/teams/updated/SEA2012/fielding.csv +39 -0
- brlib-0.2.0/tests/expected/teams/updated/SEA2012/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/updated/SEA2012/pitching.csv +20 -0
- brlib-0.2.0/tests/expected/teams/updated/WSH1904/batting.csv +31 -0
- brlib-0.2.0/tests/expected/teams/updated/WSH1904/fielding.csv +29 -0
- brlib-0.2.0/tests/expected/teams/updated/WSH1904/info.csv +2 -0
- brlib-0.2.0/tests/expected/teams/updated/WSH1904/pitching.csv +11 -0
- brlib-0.2.0/tests/test_all_major_leaguers.py +23 -0
- brlib-0.2.0/tests/test_game.py +119 -0
- brlib-0.2.0/tests/test_player.py +79 -0
- brlib-0.2.0/tests/test_team.py +75 -0
- brlib-0.0.2/.gitignore +0 -0
- brlib-0.0.2/src/brlib/__init__.py +0 -1334
- brlib-0.0.2/src/brlib/all_major_leaguers.py +0 -29
- brlib-0.0.2/src/brlib/players.py +0 -96
- brlib-0.0.2/src/brlib/teams.py +0 -113
- {brlib-0.0.2 → brlib-0.2.0}/.github/workflows/publish.yml +0 -0
- {brlib-0.0.2 → brlib-0.2.0}/LICENSE.txt +0 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/_helpers/__init__.py +0 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/_helpers/inputs.py +0 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/_helpers/requests_manager.py +0 -0
- {brlib-0.0.2 → brlib-0.2.0}/src/brlib/_helpers/singleton.py +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Tests
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
-
branches:
|
|
5
|
+
branches:
|
|
6
|
+
- '**'
|
|
6
7
|
schedule:
|
|
7
|
-
# run
|
|
8
|
-
|
|
8
|
+
# run at 12 UTC, hopefully after BR's daily in-season updates
|
|
9
|
+
# run weekly, because anything more would be overkill
|
|
10
|
+
- cron: '0 12 * * 6'
|
|
9
11
|
|
|
10
12
|
jobs:
|
|
11
13
|
pytest:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: brlib
|
|
3
|
-
Version: 0.0
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A library for collecting baseball statistics from Baseball Reference
|
|
5
5
|
Project-URL: Homepage, https://github.com/john-bieren/brlib
|
|
6
|
-
Project-URL: Documentation, https://github.com/john-bieren/brlib/
|
|
6
|
+
Project-URL: Documentation, https://github.com/john-bieren/brlib/wiki
|
|
7
7
|
Project-URL: Repository, https://github.com/john-bieren/brlib.git
|
|
8
8
|
Project-URL: Issues, https://github.com/john-bieren/brlib/issues
|
|
9
9
|
Author-email: John Bieren <jbieren64@gmail.com>
|
|
@@ -32,10 +32,10 @@ Description-Content-Type: text/markdown
|
|
|
32
32
|
|
|
33
33
|
# brlib
|
|
34
34
|
|
|
35
|
-

|
|
36
|
-
[](https://github.com/john-bieren/brlib/actions/workflows/test.yml)
|
|
36
|
+
[](https://pypi.org/project/brlib)
|
|
37
37
|
|
|
38
|
-
A
|
|
38
|
+
A library for collecting baseball statistics from [Baseball Reference](https://www.baseball-reference.com).
|
|
39
39
|
|
|
40
40
|
> [!IMPORTANT]
|
|
41
41
|
> brlib is in beta, breaking changes are possible until the release of version 1.
|
|
@@ -43,8 +43,8 @@ A Python library for collecting baseball statistics from [Baseball Reference](ht
|
|
|
43
43
|
## Key Features
|
|
44
44
|
|
|
45
45
|
* `Game`, `Player`, and `Team` classes give you easy access to all associated data in one place, with attributes for stats tables, information, and more.
|
|
46
|
-
* Aggregate these into `
|
|
47
|
-
* Quickly search for games, players, and teams of interest, and gather their stats without violating the [rate limit](https://www.sports-reference.com/
|
|
46
|
+
* Aggregate these into `GameSet`, `PlayerSet`, or `TeamSet` classes, which have similar attributes, for easy analysis of larger samples.
|
|
47
|
+
* Quickly search for games, players, and teams of interest, and gather their stats without violating the [rate limit](https://www.sports-reference.com/429.html).
|
|
48
48
|
|
|
49
49
|
Learn more by reading the documentation on the [wiki](https://github.com/john-bieren/brlib/wiki).
|
|
50
50
|
|
|
@@ -69,3 +69,7 @@ Once installed, you can import brlib into your Python scripts:
|
|
|
69
69
|
```python
|
|
70
70
|
import brlib as br
|
|
71
71
|
```
|
|
72
|
+
|
|
73
|
+
## Data Use
|
|
74
|
+
|
|
75
|
+
Since brlib gathers data from Baseball Reference, your use of this data is subject to their [data use policy](https://www.sports-reference.com/data_use.html).
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# brlib
|
|
2
2
|
|
|
3
|
-

|
|
4
|
-
[](https://github.com/john-bieren/brlib/actions/workflows/test.yml)
|
|
4
|
+
[](https://pypi.org/project/brlib)
|
|
5
5
|
|
|
6
|
-
A
|
|
6
|
+
A library for collecting baseball statistics from [Baseball Reference](https://www.baseball-reference.com).
|
|
7
7
|
|
|
8
8
|
> [!IMPORTANT]
|
|
9
9
|
> brlib is in beta, breaking changes are possible until the release of version 1.
|
|
@@ -11,8 +11,8 @@ A Python library for collecting baseball statistics from [Baseball Reference](ht
|
|
|
11
11
|
## Key Features
|
|
12
12
|
|
|
13
13
|
* `Game`, `Player`, and `Team` classes give you easy access to all associated data in one place, with attributes for stats tables, information, and more.
|
|
14
|
-
* Aggregate these into `
|
|
15
|
-
* Quickly search for games, players, and teams of interest, and gather their stats without violating the [rate limit](https://www.sports-reference.com/
|
|
14
|
+
* Aggregate these into `GameSet`, `PlayerSet`, or `TeamSet` classes, which have similar attributes, for easy analysis of larger samples.
|
|
15
|
+
* Quickly search for games, players, and teams of interest, and gather their stats without violating the [rate limit](https://www.sports-reference.com/429.html).
|
|
16
16
|
|
|
17
17
|
Learn more by reading the documentation on the [wiki](https://github.com/john-bieren/brlib/wiki).
|
|
18
18
|
|
|
@@ -37,3 +37,7 @@ Once installed, you can import brlib into your Python scripts:
|
|
|
37
37
|
```python
|
|
38
38
|
import brlib as br
|
|
39
39
|
```
|
|
40
|
+
|
|
41
|
+
## Data Use
|
|
42
|
+
|
|
43
|
+
Since brlib gathers data from Baseball Reference, your use of this data is subject to their [data use policy](https://www.sports-reference.com/data_use.html).
|
|
@@ -37,7 +37,7 @@ dev = ["pytest>=9.0.0"]
|
|
|
37
37
|
|
|
38
38
|
[project.urls]
|
|
39
39
|
Homepage = "https://github.com/john-bieren/brlib"
|
|
40
|
-
Documentation = "https://github.com/john-bieren/brlib/
|
|
40
|
+
Documentation = "https://github.com/john-bieren/brlib/wiki"
|
|
41
41
|
Repository = "https://github.com/john-bieren/brlib.git"
|
|
42
42
|
Issues = "https://github.com/john-bieren/brlib/issues"
|
|
43
43
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from .all_major_leaguers import all_major_leaguers
|
|
2
|
+
from .find_asg import find_asg
|
|
3
|
+
from .find_games import find_games
|
|
4
|
+
from .find_teams import find_teams
|
|
5
|
+
from .game import Game
|
|
6
|
+
from .game_set import GameSet
|
|
7
|
+
from .get_games import get_games
|
|
8
|
+
from .get_players import get_players
|
|
9
|
+
from .get_teams import get_teams
|
|
10
|
+
from .options import options
|
|
11
|
+
from .player import Player
|
|
12
|
+
from .player_set import PlayerSet
|
|
13
|
+
from .team import Team
|
|
14
|
+
from .team_set import TeamSet
|
|
15
|
+
|
|
16
|
+
__version__ = "0.2.0"
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"all_major_leaguers",
|
|
20
|
+
"find_asg",
|
|
21
|
+
"find_games",
|
|
22
|
+
"find_teams",
|
|
23
|
+
"Game",
|
|
24
|
+
"GameSet",
|
|
25
|
+
"get_games",
|
|
26
|
+
"get_players",
|
|
27
|
+
"get_teams",
|
|
28
|
+
"options",
|
|
29
|
+
"Player",
|
|
30
|
+
"PlayerSet",
|
|
31
|
+
"Team",
|
|
32
|
+
"TeamSet"
|
|
33
|
+
]
|
|
@@ -58,8 +58,7 @@ class AbbreviationsManager(Singleton):
|
|
|
58
58
|
def _load(self) -> None:
|
|
59
59
|
"""Loads abbreviations data from cache."""
|
|
60
60
|
self.df = pd.read_csv(self._cache_file)
|
|
61
|
-
self.df[
|
|
62
|
-
self.df.loc[self.df["Alias"] == "nan", "Alias"] = ""
|
|
61
|
+
self.df.loc[self.df["Alias"].isna(), "Alias"] = ""
|
|
63
62
|
|
|
64
63
|
def _get(self) -> None:
|
|
65
64
|
"""Gets abbreviations data from Baseball Reference."""
|
|
@@ -122,7 +121,7 @@ class AbbreviationsManager(Singleton):
|
|
|
122
121
|
Can return an empty DataFrame if there is no match.
|
|
123
122
|
|
|
124
123
|
If `era_adjustment` is True, the return DataFrame will contain the row associated with
|
|
125
|
-
`
|
|
124
|
+
`abbreviation`'s franchise during `season` even if the abbreviation is not correct.
|
|
126
125
|
For example, `self._find_correct_teams("FLA", 2025, True)` returns the `MIA` team row.
|
|
127
126
|
There can be multiple rows in the return DataFrame if an abbreviation, e.g. `BAL`,
|
|
128
127
|
is valid during a season, e.g. 1915, and is also associated with a franchise that
|
|
@@ -49,6 +49,7 @@ else:
|
|
|
49
49
|
CACHE_TIMEZONE = pytz.timezone("US/Aleutian")
|
|
50
50
|
|
|
51
51
|
# pre-compiled regular expressions
|
|
52
|
+
MULTI_TEAM_REGEX = re.compile("^[1-9]TM$")
|
|
52
53
|
SEASON_REGEX = re.compile("^[1-2][0-9]{3}$")
|
|
53
54
|
SEASON_RANGE_REGEX = re.compile("^[1-2][0-9]{3}-[1-2][0-9]{3}$")
|
|
54
55
|
GAME_DATE_REGEX = re.compile("^[0-9]{4}[0-1][0-9][0-3][0-9]$")
|
|
@@ -57,11 +58,11 @@ DATE_REGEX = re.compile("^[0-1]?[0-9][0-3][0-9]$")
|
|
|
57
58
|
DATE_RANGE_REGEX = re.compile("^[0-1]?[0-9][0-3][0-9]-[0-1]?[0-9][0-3][0-9]$")
|
|
58
59
|
PLAYER_ID_REGEX = re.compile("^[a-z.'_]{3,7}[0-9]{2}$")
|
|
59
60
|
SCHEDULE_TAG_REGEX = re.compile("^all_[0-9]")
|
|
60
|
-
GAME_URL_REGEX = re.compile(r"https
|
|
61
|
-
ALLSTAR_GAME_URL_REGEX = re.compile(r"https
|
|
62
|
-
PLAYER_URL_REGEX = re.compile(r"https
|
|
63
|
-
TEAM_URL_REGEX = re.compile(r"https
|
|
64
|
-
SB_ATTEMPT_REGEX = re.compile(r"^(?P<base>2nd base|3rd base|Home) (?:off|by) (?P<pitcher>\D+)
|
|
61
|
+
GAME_URL_REGEX = re.compile(r"https://www\.baseball-reference\.com/boxes/[A-Z1-2]{2,3}/[A-Z1-2]{2,3}[0-9]{4}[0-1][0-9][0-3][0-9][0-3]\.shtml")
|
|
62
|
+
ALLSTAR_GAME_URL_REGEX = re.compile(r"https://www\.baseball-reference\.com/allstar/[1-2][0-9]{3}-allstar-game-?[1-2]?\.shtml")
|
|
63
|
+
PLAYER_URL_REGEX = re.compile(r"https://www\.baseball-reference\.com/players/[a-z]/[a-z.'_]{3,7}[0-9]{2}\.shtml")
|
|
64
|
+
TEAM_URL_REGEX = re.compile(r"https://www\.baseball-reference\.com/teams/[A-Z1-4]{2,3}/[1-2][0-9]{3}\.shtml")
|
|
65
|
+
SB_ATTEMPT_REGEX = re.compile(r"^(?P<base>2nd base|3rd base|Home) (?:off|by) (?P<pitcher>\D+)/(?P<catcher>\D+)(?P<times>[0-9]?)$")
|
|
65
66
|
PICKOFF_REGEX = re.compile(r"^(?P<base>1st base|2nd base|3rd base|Home) by (?P<pitcher>\D+)(?P<times>[0-9]?)$")
|
|
66
67
|
|
|
67
68
|
# old names for teams (which have box scores) that didn't relocate
|
|
@@ -105,54 +106,52 @@ RANGE_TEAM_REPLACEMENTS = (
|
|
|
105
106
|
(1901, 1960, "Washington Senators", "Washington Nationals (1901-1960)")
|
|
106
107
|
)
|
|
107
108
|
|
|
108
|
-
#
|
|
109
|
+
# map all names of a venue to its best known name, or current name, if applicable
|
|
109
110
|
VENUE_REPLACEMENTS = {
|
|
110
|
-
"
|
|
111
|
-
"
|
|
111
|
+
"Miller Park": "American Family Field",
|
|
112
|
+
"Anaheim Stadium": "Angel Stadium of Anaheim",
|
|
113
|
+
"Edison Field": "Angel Stadium of Anaheim",
|
|
112
114
|
"BB&T Park": "Bowman Field",
|
|
113
115
|
"Muncy Bank Ballpark": "Bowman Field",
|
|
114
116
|
"Journey Bank Ballpark": "Bowman Field",
|
|
117
|
+
"3Com Park": "Candlestick Park",
|
|
115
118
|
"Bank One Ballpark": "Chase Field",
|
|
116
119
|
"White Sox Park": "Comiskey Park I",
|
|
117
|
-
"U.S. Cellular Field": "Comiskey Park II",
|
|
118
|
-
"Guaranteed Rate Field": "Comiskey Park II",
|
|
119
|
-
"Rate Field": "Comiskey Park II",
|
|
120
120
|
"Mile High Stadium": "Coors Field",
|
|
121
121
|
"Redland Field": "Crosley Field",
|
|
122
122
|
"Enron Field": "Daikin Park",
|
|
123
123
|
"Minute Maid Park": "Daikin Park",
|
|
124
|
-
"The Ballpark in Arlington": "Globe Life Park",
|
|
125
|
-
"Ameriquest Field": "Globe Life Park",
|
|
126
|
-
"Rangers Ballpark in Arlington": "Globe Life Park",
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"Dolphin Stadium": "Hard Rock Stadium",
|
|
131
|
-
"Dolphins Stadium": "Hard Rock Stadium",
|
|
132
|
-
"Pro Player Stadium": "Hard Rock Stadium",
|
|
124
|
+
"The Ballpark in Arlington": "Globe Life Park in Arlington",
|
|
125
|
+
"Ameriquest Field": "Globe Life Park in Arlington",
|
|
126
|
+
"Rangers Ballpark in Arlington": "Globe Life Park in Arlington",
|
|
127
|
+
"Comiskey Park II": "Rate Field",
|
|
128
|
+
"U.S. Cellular Field": "Rate Field",
|
|
129
|
+
"Guaranteed Rate Field": "Rate Field",
|
|
133
130
|
"Joe Robbie Stadium": "Hard Rock Stadium",
|
|
131
|
+
"Pro Player Stadium": "Hard Rock Stadium",
|
|
132
|
+
"Dolphins Stadium": "Hard Rock Stadium",
|
|
133
|
+
"Dolphin Stadium": "Hard Rock Stadium",
|
|
134
|
+
"Land Shark Stadium": "Hard Rock Stadium",
|
|
135
|
+
"Sun Life Stadium": "Hard Rock Stadium",
|
|
134
136
|
"Royals Stadium": "Kauffman Stadium",
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"O.co Coliseum": "Oakland Coliseum",
|
|
142
|
-
"RingCentral Coliseum": "Oakland Coliseum",
|
|
143
|
-
"AT&T Park": "Oracle Park",
|
|
144
|
-
"SBC Park": "Oracle Park",
|
|
137
|
+
"Marlins Park": "loanDepot park",
|
|
138
|
+
"Oakland Coliseum": "Oakland-Alameda County Coliseum",
|
|
139
|
+
"Network Associates Coliseum": "Oakland-Alameda County Coliseum",
|
|
140
|
+
"McAfee Coliseum": "Oakland-Alameda County Coliseum",
|
|
141
|
+
"O.co Coliseum": "Oakland-Alameda County Coliseum",
|
|
142
|
+
"RingCentral Coliseum": "Oakland-Alameda County Coliseum",
|
|
145
143
|
"Pacific Bell Park": "Oracle Park",
|
|
146
|
-
"
|
|
144
|
+
"SBC Park": "Oracle Park",
|
|
145
|
+
"AT&T Park": "Oracle Park",
|
|
147
146
|
"Jacobs Field": "Progressive Field",
|
|
148
147
|
"Cinergy Field": "Riverfront Stadium",
|
|
149
148
|
"SkyDome": "Rogers Centre",
|
|
150
|
-
"
|
|
151
|
-
"Qualcomm Stadium": "
|
|
149
|
+
"San Diego Stadium": "Jack Murphy Stadium",
|
|
150
|
+
"Qualcomm Stadium": "Jack Murphy Stadium",
|
|
152
151
|
"Connie Mack Stadium": "Shibe Park",
|
|
152
|
+
"Safeco Field": "T-Mobile Park",
|
|
153
153
|
"Navin Field": "Tiger Stadium",
|
|
154
154
|
"Briggs Stadium": "Tiger Stadium",
|
|
155
|
-
"Safeco Field": "T-Mobile Park",
|
|
156
155
|
"SunTrust Park": "Truist Park",
|
|
157
156
|
"Weeghman Park": "Wrigley Field",
|
|
158
157
|
"Cubs Park": "Wrigley Field",
|
|
@@ -233,7 +232,24 @@ MISSING_SEASONS_DICT = {
|
|
|
233
232
|
1940: {"JRC"}
|
|
234
233
|
}
|
|
235
234
|
|
|
236
|
-
#
|
|
235
|
+
# some games need their winners altered due to forfeits (https://www.retrosheet.org/forfeits.htm)
|
|
236
|
+
FORFEITED_GAME_WINNERS = {
|
|
237
|
+
"NY1190105130": "New York Giants",
|
|
238
|
+
"DET190105310": "Detroit Tigers",
|
|
239
|
+
"CLE190107230": "Washington Senators",
|
|
240
|
+
"PIT190508050": "Pittsburgh Pirates",
|
|
241
|
+
"NYA190609032": "New York Highlanders",
|
|
242
|
+
"SLN190710051": "St. Louis Cardinals",
|
|
243
|
+
"NY1190910042": "New York Giants",
|
|
244
|
+
"CHN191607180": "Brooklyn Robins",
|
|
245
|
+
"CHA191709090": "Chicago White Sox",
|
|
246
|
+
"WS1194108150": "Boston Red Sox",
|
|
247
|
+
"NY1194209262": "Boston Braves",
|
|
248
|
+
"WS2197109300": "New York Yankees",
|
|
249
|
+
"CLE197406040": "Texas Rangers"
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
# for distinguishing between league and team abbreviations when processing player career totals
|
|
237
253
|
LEAGUE_ABVS = {
|
|
238
254
|
"WS", "NL", "AL", "NNL", "NN2", "NAL", "ECL", "ANL",
|
|
239
255
|
"EWL", "NSL", "FL", "AA", "PL", "UA", "NA"
|
|
@@ -315,12 +331,11 @@ GAME_INFO_COLS = (
|
|
|
315
331
|
"Innings",
|
|
316
332
|
"Field Condition",
|
|
317
333
|
"Temperature",
|
|
318
|
-
"
|
|
334
|
+
"Wind Speed",
|
|
319
335
|
"Wind Direction",
|
|
320
336
|
"Weather",
|
|
321
337
|
"Precipitation",
|
|
322
|
-
"Game Type"
|
|
323
|
-
"Doubleheader"
|
|
338
|
+
"Game Type"
|
|
324
339
|
)
|
|
325
340
|
|
|
326
341
|
GAME_BATTING_COLS = (
|
|
@@ -482,12 +497,6 @@ GAME_TEAM_INFO_COLS = (
|
|
|
482
497
|
"Game ID"
|
|
483
498
|
)
|
|
484
499
|
|
|
485
|
-
GAME_UMP_INFO_COLS = (
|
|
486
|
-
"Game ID",
|
|
487
|
-
"Position",
|
|
488
|
-
"Umpire"
|
|
489
|
-
)
|
|
490
|
-
|
|
491
500
|
PLAYER_INFO_COLS = (
|
|
492
501
|
"Player",
|
|
493
502
|
"Player ID",
|
|
@@ -510,9 +519,9 @@ PLAYER_INFO_COLS = (
|
|
|
510
519
|
"Draft Pick",
|
|
511
520
|
"Draft Year",
|
|
512
521
|
"Draft Type",
|
|
513
|
-
"High
|
|
522
|
+
"High Schools",
|
|
514
523
|
"Schools",
|
|
515
|
-
"Debut",
|
|
524
|
+
"Debut Date",
|
|
516
525
|
"Debut Game ID",
|
|
517
526
|
"Debut Age",
|
|
518
527
|
"Debut Age (Days)",
|
|
@@ -521,11 +530,11 @@ PLAYER_INFO_COLS = (
|
|
|
521
530
|
"Last Game ID",
|
|
522
531
|
"Last Game Age",
|
|
523
532
|
"Last Game Age (Days)",
|
|
524
|
-
"Exceeded Rookie Limits",
|
|
525
|
-
"Full Name",
|
|
526
533
|
"HOF Year",
|
|
527
534
|
"HOF Type",
|
|
528
535
|
"HOF %",
|
|
536
|
+
"Exceeded Rookie Limits",
|
|
537
|
+
"Full Name",
|
|
529
538
|
"bWAR",
|
|
530
539
|
"Years Played",
|
|
531
540
|
"Minimum Career Earnings",
|
|
@@ -763,6 +772,7 @@ PLAYER_FIELDING_COLS = (
|
|
|
763
772
|
"CS%",
|
|
764
773
|
"lgCS%",
|
|
765
774
|
"Pick",
|
|
775
|
+
"Salary",
|
|
766
776
|
"AS",
|
|
767
777
|
"GG",
|
|
768
778
|
"SS",
|
|
@@ -788,7 +798,7 @@ TEAM_INFO_COLS = (
|
|
|
788
798
|
"General Manager",
|
|
789
799
|
"Farm Director",
|
|
790
800
|
"Scouting Director",
|
|
791
|
-
"
|
|
801
|
+
"Venue",
|
|
792
802
|
"Attendance",
|
|
793
803
|
"Attendance Rank",
|
|
794
804
|
"Multi-Year Batting Park Factor",
|
|
@@ -799,7 +809,7 @@ TEAM_INFO_COLS = (
|
|
|
799
809
|
"Pythagorean Losses",
|
|
800
810
|
"Team Gold Glove",
|
|
801
811
|
"Pennant",
|
|
802
|
-
"
|
|
812
|
+
"World Series"
|
|
803
813
|
)
|
|
804
814
|
|
|
805
815
|
TEAM_BATTING_COLS = (
|
|
@@ -114,16 +114,19 @@ class NoHitterDicts(Singleton):
|
|
|
114
114
|
records = []
|
|
115
115
|
for row in individual_table.find_all("tr"):
|
|
116
116
|
record = [ele.text.strip("*") for ele in row.find_all(["th", "td"])]
|
|
117
|
-
records.append(record[:
|
|
117
|
+
records.append(record[:9])
|
|
118
118
|
individual_df = pd.DataFrame(
|
|
119
119
|
records,
|
|
120
|
-
columns=("Rk", "Name", "Perfect", "Gcar", "Gtm", "Year", "Date", "Team")
|
|
120
|
+
columns=("Rk", "Name", "Perfect", "Gcar", "Gtm", "Year", "Date", "Team", "Home/Away")
|
|
121
121
|
)
|
|
122
122
|
# remove the header rows which appear every 25 rows
|
|
123
123
|
individual_df = individual_df.loc[individual_df["Name"] != "Name"].reset_index(drop=True)
|
|
124
124
|
individual_df["Game Type"] = "R"
|
|
125
125
|
postseason_mask = ((individual_df["Gcar"] == "") &
|
|
126
|
-
|
|
126
|
+
# before FIRST_GAMES_YEAR, Gcar is always blank
|
|
127
|
+
(individual_df["Year"].astype(int) >= FIRST_GAMES_YEAR) &
|
|
128
|
+
# Gcar is blank and Home/Away is "?" for regular season Negro League NHs
|
|
129
|
+
(individual_df["Home/Away"] != "?"))
|
|
127
130
|
individual_df.loc[postseason_mask, "Game Type"] = "P"
|
|
128
131
|
individual_df.loc[individual_df["Perfect"] == "", "Perfect"] = "N"
|
|
129
132
|
individual_df = individual_df.reindex(
|
|
@@ -142,7 +145,11 @@ class NoHitterDicts(Singleton):
|
|
|
142
145
|
game_id_column.append(game_id)
|
|
143
146
|
|
|
144
147
|
individual_df["Player ID"] = player_id_column
|
|
148
|
+
# fix the only exception to postseason_mask
|
|
149
|
+
individual_df.loc[individual_df["Player ID"] == "griercl01", "Game Type"] = "P"
|
|
150
|
+
|
|
145
151
|
individual_df["Game ID"] = individual_df["Game ID"].astype("object")
|
|
152
|
+
# filter out games without box scores and IDs
|
|
146
153
|
individual_df.loc[
|
|
147
154
|
(~individual_df["Team"].isin(BML_TEAM_ABVS)) &
|
|
148
155
|
(individual_df["Year"].astype(int) >= FIRST_GAMES_YEAR),
|
|
@@ -156,16 +163,17 @@ class NoHitterDicts(Singleton):
|
|
|
156
163
|
records = []
|
|
157
164
|
for row in combined_table.find_all("tr"):
|
|
158
165
|
record = [ele.text.strip("*") for ele in row.find_all(["th", "td"])]
|
|
159
|
-
records.append(record[:
|
|
166
|
+
records.append(record[:9])
|
|
160
167
|
combined_df = pd.DataFrame(
|
|
161
168
|
records,
|
|
162
|
-
columns=("Rk", "Year", "Date", "Team", "Home/Away", "Opp", "Rslt", "Name", "Gcar"
|
|
169
|
+
columns=("Rk", "Year", "Date", "Team", "Home/Away", "Opp", "Rslt", "Name", "Gcar")
|
|
163
170
|
)
|
|
164
171
|
# remove the header rows which appear every 25 rows
|
|
165
172
|
combined_df = combined_df.loc[combined_df["Name"] != "Name"].reset_index(drop=True)
|
|
166
173
|
combined_df["Game Type"] = "R"
|
|
167
174
|
postseason_mask = ((combined_df["Gcar"] == "") &
|
|
168
|
-
|
|
175
|
+
# Gcar is blank and Home/Away is "?" for regular season Negro League NHs
|
|
176
|
+
(combined_df["Home/Away"] != "?"))
|
|
169
177
|
combined_df.loc[postseason_mask, "Game Type"] = "P"
|
|
170
178
|
combined_df = combined_df.reindex(
|
|
171
179
|
columns=["Player ID", "Perfect", "Combined", "Year", "Team", "Game ID", "Game Type"]
|
|
@@ -191,12 +199,12 @@ class NoHitterDicts(Singleton):
|
|
|
191
199
|
player_id_column.append(player_id)
|
|
192
200
|
elif href.startswith("/boxes"):
|
|
193
201
|
game_id = str_between(href, "/", ".", anchor="end")
|
|
194
|
-
# filter out links to non-
|
|
202
|
+
# filter out links to non-existent pages
|
|
195
203
|
if game_id[:-9] not in BML_TEAM_ABVS:
|
|
196
204
|
game_id_column.append(game_id)
|
|
197
205
|
|
|
198
206
|
combined_df["Player ID"] = player_id_column
|
|
199
|
-
combined_df["Game ID"] = combined_df["Game ID"].astype("object")
|
|
207
|
+
combined_df["Game ID"] = combined_df["Game ID"].astype("object") # cast to nullable dtype
|
|
200
208
|
combined_df.loc[
|
|
201
209
|
(~combined_df["Team"].isin(BML_TEAM_ABVS)) &
|
|
202
210
|
(combined_df["Year"].astype(int) >= FIRST_GAMES_YEAR),
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
"""Defines utility functions used throughout the codebase."""
|
|
4
4
|
|
|
5
5
|
import functools
|
|
6
|
+
import typing
|
|
6
7
|
from collections.abc import Callable
|
|
7
8
|
from datetime import datetime
|
|
8
9
|
from types import UnionType
|
|
9
|
-
from typing import Any
|
|
10
|
+
from typing import Any
|
|
10
11
|
|
|
11
12
|
import pandas as pd
|
|
12
13
|
from bs4 import BeautifulSoup as bs
|
|
@@ -18,7 +19,7 @@ from tqdm import tqdm
|
|
|
18
19
|
def report_on_exc(resp_index: int = 1) -> Callable[..., Any]:
|
|
19
20
|
"""
|
|
20
21
|
Prints the URL of a page which causes an exception.
|
|
21
|
-
`resp_index` is the index of the decorated function's Response
|
|
22
|
+
`resp_index` is the index of the decorated function's Response argument which
|
|
22
23
|
corresponds to the offending page.
|
|
23
24
|
"""
|
|
24
25
|
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
@@ -40,7 +41,7 @@ def runtime_typecheck(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
|
40
41
|
Raises a TypeError at runtime if values passed to the function
|
|
41
42
|
do not match its type annotations.
|
|
42
43
|
"""
|
|
43
|
-
hints = get_type_hints(func)
|
|
44
|
+
hints = typing.get_type_hints(func)
|
|
44
45
|
|
|
45
46
|
@functools.wraps(func)
|
|
46
47
|
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
@@ -61,11 +62,11 @@ def is_type(value: Any, expected_type: type) -> bool:
|
|
|
61
62
|
if expected_type == Any:
|
|
62
63
|
return True
|
|
63
64
|
|
|
64
|
-
origin = get_origin(expected_type)
|
|
65
|
+
origin = typing.get_origin(expected_type)
|
|
65
66
|
if origin is None:
|
|
66
67
|
return isinstance(value, expected_type)
|
|
67
68
|
|
|
68
|
-
args = get_args(expected_type)
|
|
69
|
+
args = typing.get_args(expected_type)
|
|
69
70
|
if origin is UnionType:
|
|
70
71
|
return any(is_type(value, arg) for arg in args)
|
|
71
72
|
|
|
@@ -97,10 +98,10 @@ def str_between(string: str, start: str, end: str, anchor: str = "start") -> str
|
|
|
97
98
|
Returns the substring of `string` which appears between `start` and `end`.
|
|
98
99
|
`string` must contain `start` and `end`.
|
|
99
100
|
|
|
100
|
-
If `anchor` == "start"
|
|
101
|
+
If `anchor` == `"start"`, the substring between the first occurrence of `start`
|
|
101
102
|
and the first subsequent occurrence of `end` will be returned.
|
|
102
103
|
|
|
103
|
-
If `anchor` == "end"
|
|
104
|
+
If `anchor` == `"end"`, the substring between the final occurrence of `end`
|
|
104
105
|
and the final prior occurrence of `start` will be returned.
|
|
105
106
|
"""
|
|
106
107
|
if start not in string:
|
|
@@ -120,10 +121,14 @@ def str_remove(string: str, *substrings: str) -> str:
|
|
|
120
121
|
string = string.replace(substring, "")
|
|
121
122
|
return string
|
|
122
123
|
|
|
124
|
+
def clean_spaces(string: str) -> str:
|
|
125
|
+
"""Removes consecutive, leading, and trailing spaces from `string`."""
|
|
126
|
+
return " ".join(string.split()).strip()
|
|
127
|
+
|
|
123
128
|
def reformat_date(string_date: str) -> str:
|
|
124
129
|
"""
|
|
125
|
-
Converts `string_date` of "
|
|
126
|
-
If `string_date` does not match this format,
|
|
130
|
+
Converts `string_date` of "Month DD, YYYY" to "YY-MM-DD" for formatting consistency.
|
|
131
|
+
If `string_date` does not match this format, an empty string will be returned.
|
|
127
132
|
"""
|
|
128
133
|
try:
|
|
129
134
|
date = datetime.strptime(string_date, "%B %d, %Y")
|
|
@@ -135,7 +140,7 @@ def reformat_date(string_date: str) -> str:
|
|
|
135
140
|
day = f"0{day}" if day < 10 else day
|
|
136
141
|
return f"{date.year}-{month}-{day}"
|
|
137
142
|
|
|
138
|
-
def soup_from_comment(tag: Tag, only_if_table: bool
|
|
143
|
+
def soup_from_comment(tag: Tag, only_if_table: bool) -> bs | Tag:
|
|
139
144
|
"""
|
|
140
145
|
Returns contents from the first comment within `tag`.
|
|
141
146
|
If `tag` does not include a table and `only_if_table` == True, returns `tag`.
|
|
@@ -149,7 +154,7 @@ def soup_from_comment(tag: Tag, only_if_table: bool = False) -> bs | Tag:
|
|
|
149
154
|
except (IndexError, ValueError):
|
|
150
155
|
return tag
|
|
151
156
|
|
|
152
|
-
def scrape_player_ids(table: bs) -> list[str]:
|
|
157
|
+
def scrape_player_ids(table: bs | Tag) -> list[str]:
|
|
153
158
|
"""Returns player IDs from anchor tags in `table`."""
|
|
154
159
|
player_id_column = []
|
|
155
160
|
for row in table.find_all("a", href=True):
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Defines all_major_leaguers function."""
|
|
4
|
+
|
|
5
|
+
from io import StringIO
|
|
6
|
+
|
|
7
|
+
import pandas as pd
|
|
8
|
+
|
|
9
|
+
from ._helpers.requests_manager import req_man
|
|
10
|
+
from .options import print_page
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def all_major_leaguers() -> pd.DataFrame:
|
|
14
|
+
"""
|
|
15
|
+
Returns a DataFrame of basic information about all players in major league history.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
None
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
`pandas.DataFrame`
|
|
24
|
+
|
|
25
|
+
## Examples
|
|
26
|
+
|
|
27
|
+
The output (as of 2025-26 offseason):
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
>>> br.all_major_leaguers()
|
|
31
|
+
Player ID Name Career Start Career End Active
|
|
32
|
+
0 aardsda01 David Aardsma 2004 2015 False
|
|
33
|
+
1 aaronha01 Henry Aaron 1954 1976 False
|
|
34
|
+
2 aaronto01 Tommie Aaron 1962 1971 False
|
|
35
|
+
3 aasedo01 Don Aase 1977 1990 False
|
|
36
|
+
4 abadan01 Andy Abad 2001 2006 False
|
|
37
|
+
... ... ... ... ... ...
|
|
38
|
+
23610 zupofr01 Frank Zupo 1957 1961 False
|
|
39
|
+
23611 zuvelpa01 Paul Zuvella 1982 1991 False
|
|
40
|
+
23612 zuverge01 George Zuverink 1951 1959 False
|
|
41
|
+
23613 zwilldu01 Dutch Zwilling 1910 1916 False
|
|
42
|
+
23614 zychto01 Tony Zych 2015 2017 False
|
|
43
|
+
|
|
44
|
+
[23615 rows x 5 columns]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
You can filter results and convert them into a `get_players` input:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
>>> aml = br.all_major_leaguers()
|
|
51
|
+
>>> mask = aml["Player ID"].str.startswith("q")
|
|
52
|
+
>>> aml = aml.loc[mask]
|
|
53
|
+
>>> aml["Player ID"].values.tolist()
|
|
54
|
+
['quackke01', 'quallch01', 'quallji01', ...]
|
|
55
|
+
```
|
|
56
|
+
"""
|
|
57
|
+
page = req_man.get_page("/short/inc/players_search_list.csv")
|
|
58
|
+
print_page("All MLB Players")
|
|
59
|
+
csv_lines = str(page.content, "UTF-8").strip()
|
|
60
|
+
# add column names, which are not included in the payload
|
|
61
|
+
columns = "Player ID,Name,Career Span,Active,1,2,3,4,5\n"
|
|
62
|
+
players_df = pd.read_csv(StringIO(columns + csv_lines))
|
|
63
|
+
|
|
64
|
+
# split career span into start and end (if span is one year, only year is listed, no range)
|
|
65
|
+
players_df["Career Start"] = players_df["Career Span"].str.split("-", n=1).str[0].astype(int)
|
|
66
|
+
players_df["Career End"] = players_df["Career Span"].str.split("-", n=1).str[-1].astype(int)
|
|
67
|
+
# convert active column from 0/1 to boolean
|
|
68
|
+
players_df["Active"] = players_df["Active"].astype(bool)
|
|
69
|
+
|
|
70
|
+
columns = ["Player ID", "Name", "Career Start", "Career End", "Active"]
|
|
71
|
+
players_df = players_df.reindex(columns=columns)
|
|
72
|
+
return players_df
|