From 8cea48457fe36e180480d7f2c341e73f88406a54 Mon Sep 17 00:00:00 2001 From: Anthony Correa Date: Thu, 28 Aug 2025 15:17:07 -0500 Subject: [PATCH] Fix docstring indentation and add comments in load_games function - Adjusted docstring formatting for clarity and correctness - Added inline comments explaining key steps in load_games function --- compute_ratings.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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")