mask_missing_values#

fastcan.utils.mask_missing_values(*arrays, return_mask=False)#

Remove missing values for all arrays.

Parameters:
  • *arrays (sequence of array-like of shape (n_samples,) or (n_samples, n_outputs)) – Arrays with consistent first dimension.

  • return_mask (bool, default=False) – If True, return a mask of valid values. If False, return the arrays with missing values removed.

Returns:

  • mask_valid (ndarray of shape (n_samples,)) – Mask of valid values.

  • masked_arrays (sequence of array-like of shape (n_samples,) or (n_samples, n_outputs)) – Arrays with missing values removed. The order of the arrays is the same as the input arrays.

Examples

>>> import numpy as np
>>> from fastcan.utils import mask_missing_values
>>> a = [[1, 2], [3, np.nan], [5, 6]]
>>> b = [1, 2, 3]
>>> mask_missing_values(a, b)
[[[1, 2], [5, 6]], [1, 3]]
>>> mask_missing_values(a, b, return_mask=True)
array([ True, False,  True])