01.numpy中判断None和nan方法

1.None和nan表达的含义

import numpy as np
from numpy import NaN
>>> print(type(None))
<class 'NoneType'>
>>> print(type(NaN))
<class 'float'>

2. numpy中去除None和nan数值的方法

>>> import numpy as np
>>> a = np.array([1,2,3,None])
>>> a[a != np.array(None)]
array([1, 2, 3], dtype=object)
>>> from numpy import NaN
>>> b = np.array([1,2,3,NaN])
>>> b[~np.isnan(b)]
array([1., 2., 3.])

你可能感兴趣的:(numpy,python,numpy,机器学习,深度学习)