Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp unit is not respected #27490

Closed
Tracked by #46587
david-cortes opened this issue Jul 20, 2019 · 3 comments
Closed
Tracked by #46587

Timestamp unit is not respected #27490

david-cortes opened this issue Jul 20, 2019 · 3 comments
Labels
Bug Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas Non-Nano datetime64/timedelta64 with non-nanosecond resolution

Comments

@david-cortes
Copy link
Contributor

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
@TomAugspurger
Copy link
Contributor

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.

@jbrockmendel jbrockmendel added the Datetime Datetime data dtype label Oct 16, 2019
@mroeschke mroeschke added Bug Error Reporting Incorrect or improved errors from pandas labels Apr 2, 2020
@marceloid
Copy link

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.

@jbrockmendel jbrockmendel added the Non-Nano datetime64/timedelta64 with non-nanosecond resolution label Jan 10, 2022
@jbrockmendel
Copy link
Member

In 2.0 pandas supports s, ms, us, and ns. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas Non-Nano datetime64/timedelta64 with non-nanosecond resolution
Projects
None yet
Development

No branches or pull requests

5 participants