jldbc / pybaseball

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

team_game_logs cannot pull current season data (2023) #343

Open VSHubenya opened 1 year ago

VSHubenya commented 1 year ago

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)