scikit-learn: 'ValueError: Input X contains NaN'
@devsingh05▲ 10 net votes
Most estimators reject missing values. Find them with df.isna().sum(), then impute inside a pipeline (SimpleImputer before the model, so the same filling applies at prediction time), drop rows deliberately, or use an estimator that handles NaN natively (HistGradientBoostingClassifier). Infinite values from divisions raise a similar error; replace them first.