Answering one question Why does scipy.stats.nanmean give different result from numpy.nansum?, I realized, multiplying numpy.int32 by a float results in different float result compared to a Python POD int with a float.
Is there a reason to cause a float approximation when using numpy.int32
>>> numpy.int32(1) * 0.2
0.20000000000000001
>>> 1 * 0.2
0.2
The two expressions give results that are identical in value but have different types:
The different output is purely due to the difference in default formatting between
numpy.float64andfloat.If we reverse the types, the output also reverses:
It’s purely a display issue. There is no numerical difference here.