Possibly a duplicate of Pandas/Python: 2D histogram fails with value error. But the solution proposed there is not working for me.
I am trying to use numpy histogram2d on 2 arrays each of size 55812. When I run the command np.histogram2d(x,y)
, I get the following error:
np.histogram2d(np.array(nlx_angle[50000:55000]),np.array(nlx_speed[50000:55000]), bins=(100,100))
File "C:\Anaconda2\lib\site-packages\numpy\lib\twodim_base.py", line 714, in histogram2d
hist, edges = histogramdd([x, y], bins, range, normed, weights)
File "C:\Anaconda2\lib\site-packages\numpy\lib\function_base.py", line 802, in histogramdd
decimal = int(-log10(mindiff)) + 6
ValueError: cannot convert float NaN to integer
I have already removed all the NaN from the data. Also, the answer to the question (link above) suggested using a subset of data, but for my application, I need to use the entire data. I am using numpy version 1.11.0
Thanks for the help!
EDIT 1
I used np.where(nlx_angle==np.nan)
and np.where(nlx_speed==np.nan)
to check for NaN and all it returned is (array([], dtype=int64), array([], dtype=int64))