jldbc / pybaseball

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

Add check on result length before adding to cache #235

Closed tjburch closed 3 years ago

tjburch commented 3 years ago

Small check prompted by issue #233. Skips caching in cases where the result is length 0.

Not an exhaustive fix (e.g. if someone is staging August code and runs statcast("2021-08-01","2021-08-31") on August 25, they'll still have a non-zero dataframe but be missing a few days). Could consider something more sophisticated using datetime in the future, but this at least provides a little protection.