Try this:
import pandas as pd
x=pd.Series([314.02,314.03])
get back:
0 314.02
1 314.03
Now, multiply the series by 100:
y=(100*x)
You get:
0 31402.0
1 31403.0
dtype: float64
Now, convert to integer type:
y.astype('int64')
you get:
0 31402
1 31402
Huh???? %$#X#$% Very weird behavior!!!
If I instead type:
y.round(0).astype('int64')
I get the expected result:
0 31402
1 31403
Is this a bug I should be reporting? Or is there some kind of subtle issue in floating point representation of 31403.0 ? I'm stumped as to why I am seeing this behavior-- the round() method fix should not be necessary, I would think....
But this is not an isolated example, happens with many floating point numbers! What am I missing?
I'm running Python 3.8.2, Pandas 1.2.5
Thanks in advance for any help in understanding this behavior.