Spaces:
Running
Running
| """Feature engineering. Stateless transforms only. Anything that fits | |
| on training data and applies to test data lives in `modeling/` — keeping | |
| that boundary clean prevents train/test leakage.""" | |
| from __future__ import annotations | |
| import pandas as pd | |
| def add_calendar_features(df: pd.DataFrame, time_col: str) -> pd.DataFrame: | |
| """Hour, day-of-week, month — useful for most temporal models.""" | |
| out = df.copy() | |
| ts = pd.to_datetime(out[time_col]) | |
| out["hour"] = ts.dt.hour | |
| out["day_of_week"] = ts.dt.dayofweek | |
| out["month"] = ts.dt.month | |
| return out | |