diff --git a/compute_ratings.py b/compute_ratings.py index 4615a42..eda23f2 100644 --- a/compute_ratings.py +++ b/compute_ratings.py @@ -41,7 +41,7 @@ def load_games( DataFrame with columns Date, HomeTeam, AwayTeam, HomeRuns, AwayRuns, Margin, Result """ df = pd.read_csv(inp) - + # Choose identifiers # Determine team ID columns based on input param home_id_col = "home_name" if team_id == "names" else "home_slug" away_id_col = "away_name" if team_id == "names" else "away_slug" @@ -49,12 +49,11 @@ def load_games( if c not in df.columns: raise ValueError(f"Missing required column: {c}") - + # Optional status filter (helps exclude postponed/canceled) # Filter for final_status if provided to exclude e.g. postponed games if final_status is not None and "status" in df.columns: df = df[df["status"].astype(str).str.lower() == str(final_status).lower()] - # Convert run columns to numeric, drop rows with missing runs or teams df = df.copy() df["home_runs"] = pd.to_numeric(df["home_runs"], errors="coerce")