Nan¶
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 [6]:
bot = np.ones(shape=(3,4))
bot[[0, 2], [1, 2]] = np.nan
bot
Out[6]:
array([[ 1., nan, 1., 1.], [ 1., 1., 1., 1.], [ 1., 1., nan, 1.]])
In [7]:
bot == np.nan
Out[7]:
array([[False, False, False, False], [False, False, False, False], [False, False, False, False]])
In [8]:
np.nan == np.nan
Out[8]:
False
In [9]:
np.nan != np.nan
Out[9]:
True
In [10]:
np.isnan(bot)
Out[10]:
array([[False, True, False, False], [False, False, False, False], [False, False, True, False]])
In [11]:
foo = np.array([1,2,3], dtype=int)
foo[0]= np.nan
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[11], line 2 1 foo = np.array([1,2,3], dtype=int) ----> 2 foo[0]= np.nan ValueError: cannot convert float NaN to integer
In [ ]: