Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lahman for changes to directory structure #251

Merged
merged 2 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pybaseball/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
from .lahman import salaries
from .lahman import schools
from .lahman import series_post
from .lahman import teams
from .lahman import teams_core
from .lahman import teams_upstream
from .lahman import teams_franchises
from .lahman import teams_half
from .lahman import download_lahman
Expand Down
59 changes: 31 additions & 28 deletions pybaseball/lahman.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from . import cache

url = "https://github.com/chadwickbureau/baseballdatabank/archive/master.zip"
base_string = "baseballdatabank-master/core"
base_string = "baseballdatabank-master"

_handle = None

Expand Down Expand Up @@ -48,86 +48,89 @@ def _get_file(tablename: str, quotechar: str = "'") -> pd.DataFrame:

# do this for every table in the lahman db so they can exist as separate functions
def parks() -> pd.DataFrame:
return _get_file('Parks.csv')
return _get_file('core/Parks.csv')

def all_star_full() -> pd.DataFrame:
return _get_file("AllstarFull.csv")
return _get_file("core/AllstarFull.csv")

def appearances() -> pd.DataFrame:
return _get_file("Appearances.csv")
return _get_file("core/Appearances.csv")

def awards_managers() -> pd.DataFrame:
return _get_file("AwardsManagers.csv")
return _get_file("contrib/AwardsManagers.csv")

def awards_players() -> pd.DataFrame:
return _get_file("AwardsPlayers.csv")
return _get_file("contrib/AwardsPlayers.csv")

def awards_share_managers() -> pd.DataFrame:
return _get_file("AwardsShareManagers.csv")
return _get_file("contrib/AwardsShareManagers.csv")

def awards_share_players() -> pd.DataFrame:
return _get_file("AwardsSharePlayers.csv")
return _get_file("contrib/AwardsSharePlayers.csv")

def batting() -> pd.DataFrame:
return _get_file("Batting.csv")
return _get_file("core/Batting.csv")

def batting_post() -> pd.DataFrame:
return _get_file("BattingPost.csv")
return _get_file("core/BattingPost.csv")

def college_playing() -> pd.DataFrame:
return _get_file("CollegePlaying.csv")
return _get_file("contrib/CollegePlaying.csv")

def fielding() -> pd.DataFrame:
return _get_file("Fielding.csv")
return _get_file("core/Fielding.csv")

def fielding_of() -> pd.DataFrame:
return _get_file("FieldingOF.csv")
return _get_file("core/FieldingOF.csv")

def fielding_of_split() -> pd.DataFrame:
return _get_file("FieldingOFsplit.csv")
return _get_file("core/FieldingOFsplit.csv")

def fielding_post() -> pd.DataFrame:
return _get_file("FieldingPost.csv")
return _get_file("core/FieldingPost.csv")

def hall_of_fame() -> pd.DataFrame:
return _get_file("HallOfFame.csv")
return _get_file("contrib/HallOfFame.csv")

def home_games() -> pd.DataFrame:
return _get_file("HomeGames.csv")
return _get_file("core/HomeGames.csv")

def managers() -> pd.DataFrame:
return _get_file("Managers.csv")
return _get_file("core/Managers.csv")

def managers_half() -> pd.DataFrame:
return _get_file("ManagersHalf.csv")
return _get_file("core/ManagersHalf.csv")

def master() -> pd.DataFrame:
# Alias for people -- the new name for master
return people()

def people() -> pd.DataFrame:
return _get_file("People.csv")
return _get_file("core/People.csv")

def pitching() -> pd.DataFrame:
return _get_file("Pitching.csv")
return _get_file("core/Pitching.csv")

def pitching_post() -> pd.DataFrame:
return _get_file("PitchingPost.csv")
return _get_file("core/PitchingPost.csv")

def salaries() -> pd.DataFrame:
return _get_file("Salaries.csv")
return _get_file("contrib/Salaries.csv")

def schools() -> pd.DataFrame:
return _get_file("Schools.csv", quotechar='"') # different here bc of doublequotes used in some school names
return _get_file("contrib/Schools.csv", quotechar='"') # different here bc of doublequotes used in some school names

def series_post() -> pd.DataFrame:
return _get_file("SeriesPost.csv")
return _get_file("core/SeriesPost.csv")

def teams() -> pd.DataFrame:
return _get_file("Teams.csv")
return _get_file("core/Teams.csv")

def teams_upstream() -> pd.DataFrame:
return _get_file("upstream/Teams.csv") # manually maintained file

def teams_franchises() -> pd.DataFrame:
return _get_file("TeamsFranchises.csv")
return _get_file("core/TeamsFranchises.csv")

def teams_half() -> pd.DataFrame:
return _get_file("TeamsHalf.csv")
return _get_file("core/TeamsHalf.csv")