spiketools.utils.data.drop_nans

spiketools.utils.data.drop_nans(data)[source]

Drop any NaNs values from an array.

Parameters:
data1d or 2d array

Data array to check and drop NaNs from.

Returns:
data1d or 2d array

Data array with NaNs removed.

Notes

For 2d arrays, this function assumes the same columns to be NaN across all rows.

Examples

Drop all NaNs values from a 1d array:

>>> data = np.array([1, 2, 3.5, np.nan, 6, 2, np.nan, 1])
>>> drop_nans(data)
array([1. , 2. , 3.5, 6. , 2. , 1. ])