Search code examples
python-3.xpandasdatetimetimedelta

Pandas: summing nanoseconds time delta to timestamp


This seems somehow a simple question, but I could not find answers to it (maybe using wrong search keywords):

import pandas as pd
pd.Timestamp(1) + pd.Timedelta(seconds=1e-9)
Out: Timestamp('1970-01-01 00:00:00.000000001')  # why? Un-intuitive

pd.Timestamp(1) + pd.Timedelta(microseconds=1e-3)
Out: Timestamp('1970-01-01 00:00:00.000000001')  # why? Un-intuitive

pd.Timestamp(1) + pd.Timedelta(nanoseconds=1)
Out: Timestamp('1970-01-01 00:00:00.000000002')  # ok, but not consistent with above ones

Even if timestamps being based on the epoch in nanoseconds would be the argument, then why this (eg) inconsistency:

pd.Timestamp(1) + pd.Timedelta(seconds=1e-9)
Out: Timestamp('1970-01-01 00:00:00.000000001')

pd.Timestamp(1) + pd.Timedelta(seconds=1e-6)
Out: Timestamp('1970-01-01 00:00:00.000001001')

Solution

  • This was a bug and was fixed here.