I find this very weird. Can someone tell me whats going on here?
>>>a = [1,0,1]
>>>np.mean(a)
0.66666666666666663
>>>2.0/3
0.6666666666666666
What's up with the 3 in the end of the output of np.mean(a)
? Why isn't it a 6 like the line below it or a 7(when rounding off)?
This is just a case of a different string representation of two different types:
They compare equal:
Now might be the time to read about
numpy
scalars andnumpy
dtypes.