jldbc / pybaseball

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

Docs provide incorrect import statements. #290

Closed samlafell closed 1 year ago

samlafell commented 1 year ago

Example Case: https://github.com/jldbc/pybaseball/blob/master/docs/statcast_pitcher.md

from pybaseball import statcast_pitcher_exitvelo_barrels

# get data for all qualified pitchers in 2019
data = statcast_pitcher_exitvelo_barrels(2019)

# get data for pitchers with a minimum of 100 batted ball events in 2019
data = statcast_pitcher_exitvelo_barrels(2019, 100)

This is wrong. The correct import is:

from pybaseball.statcast_pitcher import statcast_pitcher_exitvelo_barrels as p_ev_barrels

p_ev_barrels(2022, 25)

(Obviously the as p_ev_barrels is optional)

From what I can tell, this is a pretty widespread error across the documentation and once you figure it out, you're fine for the rest of the imports.

The code chunk I've included works fine. I would fork and PR myself but it's a lot of small changes and would like to maybe tackle it with someone else.

tjburch commented 1 year ago

Hey, thanks for reporting. This is actually a symptom of pypi/pip not picking up the newer release yet. If you install from source using the 2.2.3 version, it imports as the docs mention since it's exported in the init.py. I went through most the docs and the ones that fail to correctly import are all part of this pypi issue. We're working to resolve that now, and will close the issue after.

(Admittedly in some of my responses here I've used the pattern you've mentioned, from pybaseball.module import method, but that's not the ideal usage pattern from a user standpoint)

samlafell commented 1 year ago

Thank you tjburch! I really appreciate the reply.