I checked these two sources:
- https://pandas.pydata.org/docs/reference/api/pandas.Timestamp.value.html#pandas.Timestamp.value
- https://github.com/pandas-dev/pandas/blob/main/pandas/_libs/tslibs/timestamps.pyx
but still unclear with what it does. I'm not very familiar with cython code.
Just based on poking around, it seems to return the number of nanoseconds since epoch.
>>> import pandas as pd
>>> ts = pd.Timestamp("1970-01-01")
>>> ts.value
0
>>> ts = pd.Timestamp("1970-01-01 00:00:00.123")
>>> ts.value
123000000
>>> ts = pd.Timestamp("1969-12-31 23:59:59")
>>> ts.value
-1000000000
I wonder if it's documented somewhere.
CodePudding user response:
It's not explicitly documented, but yes - value
is the count of resolution
s (defined as Timedelta('0 days 00:00:00.000000001')
= 1 ns
) since epoch:
>>> import pandas as pd
>>> ts = pd.Timestamp("1970-01-01 00:00:00.123")
>>> ts.resolution * ts.value
Timedelta('0 days 00:00:00.123000')
See also:
The default unit is nanoseconds, since that is how Timestamp objects are stored internally.
Since pandas represents timestamps in nanosecond resolution, ...