-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
to_datetime() ns precision inconsistencies between s and ns #15817
Comments
This is not really related to #7307, but more with the (possible) precision of floats. The float "1490195805.433502912" is too large / has too high precision to be represented faithfully as a floating point. Therefore, when converting this float to a datetime64 (which representation is based on integers) you get a conversion error.
|
How do you explain the following then?
|
A string needs to be parsed to an actual floating point, and also here differences can occur based on which implementation you use:
And additionally, also floating point arithmetic will give small differences, a float * 10^9 does not necessarily result in the same number as combining both separate parts as integers |
furthermore, python floats are unbounded precision, while this is casted to a
|
@mchwalisz happy to have a short section in |
A string needs to be parsed to an actual floating point, and also here differences can occur based on which implementation you use:
And additionally, also floating point arithmetic will give small differences, a float * 10^9 does not necessarily result in the same number as combining both separate parts as integers. This is one of the reasons the timestamps are stored as integers. If you want to read more information about this issue, you can see http://floating-point-gui.de/ |
Code Sample, a copy-pastable example if possible
Output
Problem description
I would expect that all of the following methods would give the same result. In the documentation that the epoch times will be rounded to the nearest nanosecond. I don't understand why conversion from float using seconds
s
unit gives different rounding than nano secondsns
. Not to mention strange float parsing coming from csv.I expect the whole issue to be connected to #7307.
Expected Output
Output of
pd.show_versions()
pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 34.3.2
Cython: 0.25.2
numpy: 1.10.4
scipy: 0.19.0
statsmodels: None
xarray: None
IPython: 5.3.0
sphinx: 1.4.8
patsy: None
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: 3.3.0
numexpr: 2.6.2
matplotlib: 2.0.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.5.3
html5lib: 0.999999999
httplib2: 0.9.1
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.5
boto: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: