deponovo
deponovo

Reputation: 1432

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')

Upvotes: 1

Views: 527

Answers (1)

deponovo
deponovo

Reputation: 1432

This was a bug and was fixed here.

Upvotes: 1

Related Questions