Pandas:将纳秒时间增量与时间戳相加
Pandas: summing nanoseconds time delta to timestamp
这似乎是一个简单的问题,但我找不到答案(可能使用了错误的搜索关键字):
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
即使时间戳是基于以纳秒为单位的纪元的,那么为什么会出现这种(例如)不一致:
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')
这是一个错误,已修复 here。
这似乎是一个简单的问题,但我找不到答案(可能使用了错误的搜索关键字):
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
即使时间戳是基于以纳秒为单位的纪元的,那么为什么会出现这种(例如)不一致:
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')
这是一个错误,已修复 here。