In [1]:
import numpy as np
a = np.array([1, 2, 3])
np.ediff1d(a, np.nan)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-1-13abd29cafa9> in <module>
2
3 a = np.array([1, 2, 3])
----> 4 np.ediff1d(a, np.nan)
~/anaconda3/envs/ModSimPy/lib/python3.7/site-packages/numpy/lib/arraysetops.py in ediff1d(ary, to_end, to_begin)
116 l_end = 0
117 else:
--> 118 _to_end = np.asanyarray(to_end, dtype=dtype_req)
119 # check that casting has not overflowed
120 if not np.all(_to_end == to_end):
~/anaconda3/envs/ModSimPy/lib/python3.7/site-packages/numpy/core/numeric.py in asanyarray(a, dtype, order)
589
590 """
--> 591 return array(a, dtype, copy=False, order=order, subok=True)
592
593
ValueError: cannot convert float NaN to integer
In [ ]:
In [2]:
a[2] = np.nan
a
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-6f1cfd3684be> in <module>
----> 1 a[2] = np.nan
2 a
ValueError: cannot convert float NaN to integer
In [ ]:
Content source: AllenDowney/ModSimPy
Similar notebooks: