File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -231,15 +231,17 @@ def _safe_nan_clean(self, X):
231231 else :
232232 return X [~ np .any (np .isnan (X ))]
233233 elif np .issubdtype (X .dtype , np .object_ ):
234+ # Since the dtype is object we cannot apply the function np.isnan
235+ # Therefore, we need to iterate over each row
236+ # According to the number of columns we can have an array or a scalar
237+ # if it is an array then we cast it to a list and check if it contains None
238+ # if it is a scalar then we use np.isnan if it is a float or not None otherwise
234239 return X [
235240 np .array (
236241 [
237242 [
238243 not (
239- (isinstance (x , list ) and None in x )
240- or (
241- isinstance (x , np .ndarray ) and None in x .tolist ()
242- )
244+ (isinstance (x , np .ndarray ) and None in x .tolist ())
243245 or (isinstance (x , float ) and np .isnan (x ))
244246 or (x is None )
245247 )
You can’t perform that action at this time.
0 commit comments