Any / All¶
In [1]:
%pip install numpy
import numpy as np
Requirement already satisfied: numpy in /home/samrat/Documents/numpy-torch-tutorials/venv/lib/python3.8/site-packages (1.24.4) Note: you may need to restart the kernel to use updated packages.
In [2]:
foo = np.array([
[np.nan, 4.4],
[1.0, 3.2],
[np.nan, np.nan],
[0.1, np.nan]])
In [7]:
mask = np.any(np.isnan(foo), axis=1)
In [8]:
foo[mask]
Out[8]:
array([[nan, 4.4], [nan, nan], [0.1, nan]])
In [9]:
mask = np.all(np.isnan(foo), axis=1)
foo[mask]
Out[9]:
array([[nan, nan]])