Top 5 pybaseball Code Examples | Snyk

PHOTO EMBED

Thu Jul 27 2023 01:02:31 GMT+0000 (Coordinated Universal Time)

Saved by @ebeanes28 #python

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
content_copyCOPY

https://snyk.io/advisor/python/pybaseball/example