Esempio n. 1
0
def test_team_id_lookup_season_league() -> None:
    result = team_ids(2019, 'NL')

    assert result is not None
    assert not result.empty

    assert len(result.columns) == 7
    assert len(result) == 15
Esempio n. 2
0
def test_team_id_lookup_all() -> None:
    result = team_ids()

    assert result is not None
    assert not result.empty

    # Remove newer results to ensure we get the count right
    result = result.query('yearID <= 2019')

    assert len(result.columns) == 7
    assert len(result) == 2943
Esempio n. 3
0
# Package to pull data:
# https://pypi.org/project/pybaseball/
# Other Packages considered:
# https://pypi.org/project/baseball-scraper/
# https://pypi.org/project/vigorish/
# Useful source to compare packages:
# https://snyk.io/advisor/python

############## Statcast data ##############
data = statcast(start_dt='2021-04-01', end_dt='2021-04-02', team='SEA')
data.loc[data.game_date == '2021-04-01', :]
data.head()

############## Team Crosswalk #############
team_cross = teams()
team_cross = team_ids()

############# Player Crosswalk ############
player = playerid_lookup('Sheffield', 'Justus')

############## Date Range #################
dt_lst = pd.date_range(start='2021-04-01', end='2021-05-31', freq='D')
dt_range = []
for i in dt_lst:
    dt_range.append(i.strftime('%Y-%m-%d'))

############### Pitcher Profile ##############
# Game by Game
# TODO remove data.GS filter if want to look at all pitchers ; for now just looking at starters
table_lst = []
for x in dt_range: