Skip to content

Instantly share code, notes, and snippets.

@pranjalAI
Last active December 22, 2025 04:47
Show Gist options
  • Select an option

  • Save pranjalAI/fd7cba637897d97a5b664ba9eb09e304 to your computer and use it in GitHub Desktop.

Select an option

Save pranjalAI/fd7cba637897d97a5b664ba9eb09e304 to your computer and use it in GitHub Desktop.
def normalize_ipo_calendar(ipo_df: pd.DataFrame) -> pd.DataFrame:
df = ipo_df.copy()
if df.empty:
return df
# Defensive: use `.get()` so missing columns don't raise KeyError.
df["symbol"] = df.get("symbol")
df["companyName"] = df.get("companyName")
df["exchange"] = df.get("exchange")
df["ipoDate"] = pd.to_datetime(df.get("date"), errors="coerce")
# Keep only rows with a usable symbol.
df = df.dropna(subset=["symbol"])
df["symbol"] = df["symbol"].astype(str).str.strip()
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment