jldbc / pybaseball

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

stats_range but pulling stats from Fangraphs instead of Baseball Reference? #293

Open ccott235 opened 1 year ago

ccott235 commented 1 year ago

Is it possible to add a condition to have the pitching_stats_range and batting_stats_range to pull stats from Fangraphs instead of Baseball Reference? Speaking specifically to pitching stats - for some reason baseball reference has nothing on blown saves, which makes finding save percentage impossible using a time range.

tjburch commented 1 year ago

Hey, @ccott235. I think this is could be a nice functionality to add. If you're interested in contributing, I think the classes in the Fangraphs datasources file will help you see how to scrape from Fangraphs.

BrayanMnz commented 1 year ago

Thinking on the architecture ->

We could create an Enum class that includes each supported source of data and then add that as a parameter to the main functions of pybaseball project.

Based on that argument on each function we can redirect the workflow to the corresponding logic based on the source of data selected or expressed on the function.

In that way we can easily maintain the logic for scraping from each source of data separated but, not totally decoupled since there will be lot of logic shared dealed as CORE or COMMON when handling this workflow for each one of the supported source of data.

In this way we can keep the door open for any other source of data that could be included in the future without the headache of breaking the already working things.

tjburch commented 1 year ago

That would definitely be huge code overhaul. I'm not opposed in theory, but in practice I'm not sure the gain is worth the effort - in most cases there's pretty good overlap in data between similar sources. An entire rewrite just to get blown saves seems like overkill. @BrayanMnz, if you want to take a stab at it, by all means go ahead, but I'd personally be more than happy with just a small contribution that's just an additional function.

erin2722 commented 1 year ago

I am going to take a stab at adding in a small contribution to add in a function for this!