@@ -276,6 +276,9 @@ class MinMaxScaler(BaseEstimator, TransformerMixin):
276276
277277 Notes
278278 -----
279+ NaNs are treated as missing values: disregarded in fit, and maintained in
280+ transform.
281+
279282 For a comparison of the different scalers, transformers, and normalizers,
280283 see :ref:`examples/preprocessing/plot_all_scaling.py
281284 <sphx_glr_auto_examples_preprocessing_plot_all_scaling.py>`.
@@ -340,10 +343,11 @@ def partial_fit(self, X, y=None):
340343 "You may consider to use MaxAbsScaler instead." )
341344
342345 X = check_array (X , copy = self .copy , warn_on_dtype = True ,
343- estimator = self , dtype = FLOAT_DTYPES )
346+ estimator = self , dtype = FLOAT_DTYPES ,
347+ force_all_finite = "allow-nan" )
344348
345- data_min = np .min (X , axis = 0 )
346- data_max = np .max (X , axis = 0 )
349+ data_min = np .nanmin (X , axis = 0 )
350+ data_max = np .nanmax (X , axis = 0 )
347351
348352 # First pass
349353 if not hasattr (self , 'n_samples_seen_' ):
@@ -373,7 +377,8 @@ def transform(self, X):
373377 """
374378 check_is_fitted (self , 'scale_' )
375379
376- X = check_array (X , copy = self .copy , dtype = FLOAT_DTYPES )
380+ X = check_array (X , copy = self .copy , dtype = FLOAT_DTYPES ,
381+ force_all_finite = "allow-nan" )
377382
378383 X *= self .scale_
379384 X += self .min_
@@ -389,7 +394,8 @@ def inverse_transform(self, X):
389394 """
390395 check_is_fitted (self , 'scale_' )
391396
392- X = check_array (X , copy = self .copy , dtype = FLOAT_DTYPES )
397+ X = check_array (X , copy = self .copy , dtype = FLOAT_DTYPES ,
398+ force_all_finite = "allow-nan" )
393399
394400 X -= self .min_
395401 X /= self .scale_
0 commit comments