jldbc / jldbc/pybaseball

team_game_logs cannot pull current season data (2023)

Open
#343 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

Apply fix via
def postprocess(data: pd.DataFrame) -> pd.DataFrame:
data.drop("Rk", axis=1, inplace=True) # drop index column
repl_dict = {
"Gtm": "Game",
"Unnamed: 3": "Home",
"#": "NumPlayers",
"Opp. Starter (GmeSc)": "OppStart",
"Pitchers Used (Rest-GameScore-Dec)": "PitchersUsed"
}
data.rename(repl_dict, axis=1, inplace=True)
data["Home"] = data["Home"].isnull() # '@' if away, empty if home
**data = data[data["Game"].str.match(r"\d+")]** -> **data = data[data["Game"].astype(str).str.match(r"\d+")] # drop empty month rows**
data = data.apply(pd.to_numeric, errors="ignore")
data["Game"] = data["Game"].astype(int)
return data.reset_index(drop=True)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.