Timestamps always get returned in nanoseconds regardless of the unit I specify:
import numpy as np, pandas as pd
np.datetime64("2018-01-01").astype("datetime64[s]").astype(int)
>>> 1514764800
pd.Series(np.datetime64("2018-01-01")).astype("datetime64[s]")
0 2018-01-01
dtype: datetime64[ns]
pd.Series(np.datetime64("2018-01-01")).astype("datetime64[s]").astype(int)
0 1514764800000000000
dtype: int64
Comment From: TomAugspurger
Pandas doesn't support non-ns resolution.
As of pandas 0.21, we raised on the Series[datetime64[ns]].astype('datetime64[s]')
. It seems we don't raise any more, which may be a bug.
Comment From: marceloid
Can confirm that as of pandas 1.2.3 the Series[datetime64[ns]].astype('datetime64[s]')
doesn't raise any exception, and it still returns ns values.
Comment From: jbrockmendel
In 2.0 pandas supports s, ms, us, and ns. Closing.