jldbc / pybaseball

Pull current and historical baseball statistics using Python (Statcast, Baseball Reference, FanGraphs)
MIT License
1.26k stars 333 forks source link

Add mlbID to return table of batting_stats_range #264

Closed tjburch closed 2 years ago

tjburch commented 2 years ago

257 highlighted that there's no IDs returned via batting_stats_range. The scraping currently returns the MLB AM ID, we just drop it in the conversion to numerics. This PR adds it back in.

New output:

In [1]: from pybaseball.league_batting_stats import batting_stats_range

In [2]: batting_stats_range("2022-04-10", end_dt="2022-04-11").head()

Out[2]:
                Name  Age  #days     Lev           Tm  G  PA  AB  R  H  2B  3B  HR  RBI  BB  IBB  SO  HBP  SH  SF  GDP  SB  CS     BA    OBP    SLG    OPS   mlbID
1        C.J. Abrams   21     12  Maj-NL    San Diego  1   1   1  0  0   0   0   0    0   0    0   0    0   0   0    0   0   0  0.000  0.000  0.000  0.000  682928
2  Jos\xc3\xa9 Abreu   35     12  Maj-AL      Chicago  1   5   4  3  2   1   0   0    2   1    0   0    0   0   0    0   0   0  0.500  0.600  0.750  1.350  547989
3       Willy Adames   26     11  Maj-NL    Milwaukee  2   8   6  2  1   0   0   1    1   2    0   3    0   0   0    0   0   0  0.167  0.375  0.667  1.042  642715
4           Jo Adell   23     11  Maj-AL  Los Angeles  2   8   8  1  2   1   0   1    2   0    0   3    0   0   0    0   0   0  0.250  0.250  0.750  1.000  666176
5      Jesus Aguilar   32     11  Maj-NL        Miami  2   7   7  0  0   0   0   0    0   0    0   4    0   0   0    0   0   0  0.000  0.000  0.000  0.000  542583
schorrm commented 2 years ago

Can you adjust the test coverage?

tjburch commented 2 years ago

Sorry, not following - what needs to be adjusted with the test coverage? The existing test_batting_stats_range_start_dt_lt_2008 in test_league_batting_stats.py should cover this, I think.

Running locally I get all passing (a few unrelated warnings).