jldbc / pybaseball

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

pybaseball.batting_stats gives pitching stats instead of batting stats depending on the season arguments given. #273

Closed AsirShahid closed 1 year ago

AsirShahid commented 2 years ago

If I use "2022" as the season argument, I get pitching stats instead of hitting stats.

This is the result for batting_stats(2022):

IDfg Season Name Team Age W L WAR ERA G ... LA Barrels Barrel% maxEV HardHit HardHit% Events CStr% CSW% xERA
14107 2022 Kevin Gausman TOR 31 5 4 2.8 2.78 11 ... 9.6 11 0.059 116.6 74 0.400 185 0.136 0.299 3.01
22267 2022 Tarik Skubal DET 25 4 2 2.2 2.15 10 ... 11.9 7 0.045 113.1 63 0.406 155 0.169 0.287 2.68
6902 2022 Martin Perez TEX 31 4 2 2.0 1.56 11 ... 8.3 5 0.026 110.6 68 0.349 195 0.188 0.280 2.58
12970 2022 Joe Musgrove SDP 29 6 0 1.9 1.64 10 ... 9.7 8 0.045 109.8 65 0.367 177 0.200 0.313 2.62
17874 2022 Nestor Cortes NYY 27 5 1 1.9 1.50 10 ... 17.1 6 0.041 113.7 49 0.336 146 0.190 0.289 2.19
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
22182 2022 Hunter Greene CIN 22 3 7 0.0 5.40 11 ... 23.0 16 0.111 113.6 54 0.375 144 0.152 0.286 4.68
5524 2022 Madison Bumgarner ARI 32 2 5 0.0 3.64 12 ... 15.9 16 0.085 112.2 85 0.450 189 0.179 0.250 4.44
12049 2022 Kyle Hendricks CHC 32 2 5 0.0 5.22 11 ... 16.3 17 0.089 111.9 75 0.393 191 0.180 0.267 5.43
24580 2022 Josiah Gray WSN 24 6 4 -0.2 4.71 11 ... 24.8 22 0.148 110.6 60 0.403 149 0.162 0.285 4.96
15467 2022 Marco Gonzales SEA 30 3 6 -0.2 3.59 11 ... 13.9 17 0.087 111.1 74 0.379 195 0.144 0.218 4.93

This is what would be expected from pitching_stats(2022). But for any season I tried prior to 2022, it listed the hitting stats, as expected.

If I do a multi-season search, like hitting_stats(2021,2022), then the same issue occurs. It lists the pitching stats for 2021 and 2022. But when I do a multi-season search with the first year being prior to 2021, then it lists the hitting stats for the seasons, as expected.

Has anyone else experienced this issue?

AsirShahid commented 2 years ago

Disabling the cache fixed this issue.

tjburch commented 2 years ago

I believe this was addressed in #269, but not in the release version yet.

tjburch commented 1 year ago

Resolved and in pypi following closing of #281.