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

BUG(?): Non nano + DatetOffset(component=0) re-infers resolution #57448

Open
mroeschke opened this issue Feb 16, 2024 · 3 comments
Open

BUG(?): Non nano + DatetOffset(component=0) re-infers resolution #57448

mroeschke opened this issue Feb 16, 2024 · 3 comments
Labels
Frequency DateOffsets Non-Nano datetime64/timedelta64 with non-nanosecond resolution Numeric Operations Arithmetic, Comparison, and Logical operations

Comments

@mroeschke
Copy link
Member

mroeschke commented Feb 16, 2024

In [1]: import pandas as pd; from io import StringIO; import numpy as np

In [2]: ser = pd.Series(pd.DatetimeIndex(["2000-01-01 00:00:00.012"], dtype="datetime64[ms]"))

In [3]: ser
Out[3]: 
0   2000-01-01 00:00:00.012
dtype: datetime64[ms]

In [4]: ser + pd.DateOffset(microseconds=0)  # 2.1.4
Out[4]: 
0   2000-01-01 00:00:00.012
dtype: datetime64[ms]

In [3]: ser + pd.DateOffset(microseconds=0). # main
Out[3]: 
0   2000-01-01 00:00:00.012
dtype: datetime64[us]

Possibly from #55595. Should the resolution be re-inferred here? cc @jbrockmendel

@mroeschke mroeschke added Numeric Operations Arithmetic, Comparison, and Logical operations Frequency DateOffsets Non-Nano datetime64/timedelta64 with non-nanosecond resolution labels Feb 16, 2024
@jbrockmendel
Copy link
Member

i think bc you passed microseconds=0, offset._pd_timedelta comes back with unit="us", which is why this gets upcast

@mroeschke
Copy link
Member Author

Would it be worth no-oping these cases though?

@jbrockmendel
Copy link
Member

i dont think so, no. This is analogous to pd.Timedelta(0).as_unit("us") in that the "us" unit is informative despite the value being zero.

rapids-bot bot pushed a commit to rapidsai/cudf that referenced this issue Feb 20, 2024
2 tests needed to be adjusted due to pandas changes in behaviors in pandas-dev/pandas#57447 and pandas-dev/pandas#57448

Authors:
  - Matthew Roeschke (https://github.com/mroeschke)

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #15078
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frequency DateOffsets Non-Nano datetime64/timedelta64 with non-nanosecond resolution Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

No branches or pull requests

2 participants