How to use the pybaseball.utils.first_season_map function in pybaseball

To help you get started, we’ve selected a few pybaseball examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jldbc / pybaseball / pybaseball / team_results.py View on Github external
def schedule_and_record(season=None, team=None):
    # retrieve html from baseball reference
    # sanatize input
    team = team.upper()
    try:
        if season < first_season_map[team]:
            m = "Season cannot be before first year of a team's existence"
            raise ValueError(m)
    # ignore validation if team isn't found in dictionary
    except KeyError:
        pass
    if season > datetime.now().year:
        raise ValueError('Season cannot be after current year')

    soup = get_soup(season, team)
    table = get_table(soup, team)
    table = process_win_streak(table)
    table = make_numeric(table)
    return table

pybaseball

Retrieve baseball data in Python

MIT
Latest version published 1 year ago

Package Health Score

62 / 100
Full package analysis