pingouin.remove_na

pingouin.remove_na(x, y=None, paired=False, axis='rows')[source]

Remove missing values along a given axis in one or more (paired) numpy arrays.

Parameters
x, y1D or 2D arrays

Data. x and y must have the same number of dimensions. y can be None to only remove missing values in x.

pairedbool

Indicates if the measurements are paired or not.

axisstr

Axis or axes along which missing values are removed. Can be ‘rows’ or ‘columns’. This has no effect if x and y are one-dimensional arrays.

Returns
x, ynp.ndarray

Data without missing values

Examples

Single 1D array

>>> import numpy as np
>>> from pingouin import remove_na
>>> x = [6.4, 3.2, 4.5, np.nan]
>>> remove_na(x)
array([6.4, 3.2, 4.5])

With two paired 1D arrays

>>> y = [2.3, np.nan, 5.2, 4.6]
>>> remove_na(x, y, paired=True)
(array([6.4, 4.5]), array([2.3, 5.2]))

With two independent 2D arrays

>>> x = np.array([[4, 2], [4, np.nan], [7, 6]])
>>> y = np.array([[6, np.nan], [3, 2], [2, 2]])
>>> x_no_nan, y_no_nan = remove_na(x, y, paired=False)