From 4c7b3f267610d22f111081ed8779fad229f43206 Mon Sep 17 00:00:00 2001 From: Marko Djordjevic Date: Sun, 15 Feb 2026 21:58:16 +0100 Subject: [PATCH] fix(ml): detect all-NaN volume column (not just missing column) The Pydantic model sets volume=None when absent, creating an all-NaN column rather than a missing column. Check isna().all() in addition to column existence. --- services/ml/app/preprocessing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/ml/app/preprocessing.py b/services/ml/app/preprocessing.py index a4595ea..26224bb 100644 --- a/services/ml/app/preprocessing.py +++ b/services/ml/app/preprocessing.py @@ -60,9 +60,9 @@ def preprocess_candles( except Exception as e: raise ValueError(f"Candle data validation failed: {e}") - # Handle missing volume column - fill with 0 if absent - if 'volume' not in df.columns: - logger.warning("Volume column missing from candle data, filling with 0") + # Handle missing or all-null volume column - fill with 0 if absent/empty + if 'volume' not in df.columns or df['volume'].isna().all(): + logger.warning("Volume data missing from candles, filling with 0") df['volume'] = 0.0 # Get feature engineering config