@@ -265,17 +265,23 @@ Typical epoch stored units
265
265
pd.to_datetime([1349720105100 , 1349720105200 , 1349720105300 ,
266
266
1349720105400 , 1349720105500 ], unit = ' ms' )
267
267
268
- These * work *, but the results may be unexpected.
268
+ .. note ::
269
269
270
- .. ipython :: python
270
+ Epoch times will be rounded to the nearest nanosecond.
271
271
272
- pd.to_datetime([ 1 ])
272
+ .. warning ::
273
273
274
- pd.to_datetime([1 , 3.14 ], unit = ' s' )
274
+ Conversion of float epoch times can lead to inaccurate and unexpected results.
275
+ :ref: `Python floats <python:tut-fp-issues >` have about 15 digits precision in
276
+ decimal. Rounding during conversion from float to high precision ``Timestamp `` is
277
+ unavoidable. The only way to achieve exact precision is to use a fixed-width
278
+ types (e.g. an int64).
275
279
276
- .. note ::
280
+ .. ipython :: python
277
281
278
- Epoch times will be rounded to the nearest nanosecond.
282
+ 1490195805.433502912
283
+ pd.to_datetime([1490195805.433 , 1490195805.433502912 ], unit = ' s' )
284
+ pd.to_datetime(1490195805433502912 , unit = ' ns' )
279
285
280
286
.. _timeseries.origin :
281
287
@@ -300,6 +306,16 @@ Commonly called 'unix epoch' or POSIX time.
300
306
301
307
pd.to_datetime([1 , 2 , 3 ], unit = ' D' )
302
308
309
+ .. note ::
310
+
311
+ Without specifying origin the following examples still evaluate, but the results
312
+ may be unexpected.
313
+
314
+ .. ipython :: python
315
+
316
+ pd.to_datetime([1 ])
317
+ pd.to_datetime([1 , 3.14 ], unit = ' s' )
318
+
303
319
.. _timeseries.daterange :
304
320
305
321
Generating Ranges of Timestamps
0 commit comments