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 unitless np NaT arithmetic with non-nano #52821

Merged
merged 5 commits into from
Apr 22, 2023

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke added Numeric Operations Arithmetic, Comparison, and Logical operations Non-Nano datetime64/timedelta64 with non-nanosecond resolution labels Apr 21, 2023
@mroeschke mroeschke added this to the 2.0.1 milestone Apr 21, 2023
@@ -533,7 +538,11 @@ def maybe_prepare_scalar_for_op(obj, shape: Shape):
from pandas.core.arrays import DatetimeArray

# Avoid possible ambiguities with pd.NaT
obj = obj.astype("datetime64[ns]")
# GH 52295
if is_unitless(obj.dtype) or not is_supported_unit(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think in non-supported unit cases we'd want to use the closest-to-supported? could just handle the unitless case here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. We also need to handle the unsupported NaT case here too though

@phofl phofl merged commit eb9a3e8 into pandas-dev:main Apr 22, 2023
@phofl
Copy link
Member

phofl commented Apr 22, 2023

thx @mroeschke

@lumberbot-app
Copy link

lumberbot-app bot commented Apr 22, 2023

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 2.0.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 eb9a3e81a946d5921e4458632e9632239ac8e8d1
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #52821: BUG: Non unitless np NaT arithmetic with non-nano'
  1. Push to a named branch:
git push YOURFORK 2.0.x:auto-backport-of-pr-52821-on-2.0.x
  1. Create a PR against branch 2.0.x, I would have named this PR:

"Backport PR #52821 on branch 2.0.x (BUG: Non unitless np NaT arithmetic with non-nano)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

phofl pushed a commit to phofl/pandas that referenced this pull request Apr 22, 2023
phofl added a commit that referenced this pull request Apr 22, 2023
…ic with non-nano) (#52847)

BUG: Non unitless np NaT arithmetic with non-nano (#52821)

(cherry picked from commit eb9a3e8)

Co-authored-by: Matthew Roeschke <[email protected]>
@mroeschke mroeschke deleted the bug/nonnano/np_scalar_arith branch April 24, 2023 16:47
Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non-Nano datetime64/timedelta64 with non-nanosecond resolution Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Inconsistency in datetime & timedelta binary operations in pandas-2.0
3 participants