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/API: preserve non-nano in factorize/unique #51978

Merged
merged 3 commits into from
Mar 15, 2023

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Mar 15, 2023

The ugly bit here is that it causes to_datetime to behave slightly differently with cache=True/False in some cases. I know @mroeschke worked to avoid that in #17077, so it may be a deal-breaker.

But it fixes #51961 (though doesn't yet have a targeted test) so may be worth prioritizing (cc @MarcoGorelli)

(Update) also fixes Series[non-nano].factorize which currently raises AssertionError

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Looks good to be honest, I don't think I'd consider the cache vs non-cache discrepancy a blocker

msg = "Out of bounds nanosecond timestamp: 9999-01-01 00:00:00"
with pytest.raises(OutOfBoundsDatetime, match=msg):
to_datetime(dts_with_oob, errors="raise")
# As of GH#?? we do not raise in this case
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

have added this to my next CLN branch

pandas/tests/io/parser/test_parse_dates.py Show resolved Hide resolved
@mroeschke mroeschke added Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Non-Nano datetime64/timedelta64 with non-nanosecond resolution labels Mar 15, 2023
@mroeschke
Copy link
Member

But it fixes #51961 (though doesn't yet have a targeted test) so may be worth prioritizing

Fine with me to have this fix despite the cache=False bug. Could you add a test for the above too?

@mroeschke mroeschke added this to the 2.0 milestone Mar 15, 2023
@mroeschke mroeschke merged commit 6a13450 into pandas-dev:main Mar 15, 2023
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@lumberbot-app
Copy link

lumberbot-app bot commented Mar 15, 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 6a13450cec5996cc14f722069ef9be150f034e03
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #51978: BUG/API: preserve non-nano in factorize/unique'
  1. Push to a named branch:
git push YOURFORK 2.0.x:auto-backport-of-pr-51978-on-2.0.x
  1. Create a PR against branch 2.0.x, I would have named this PR:

"Backport PR #51978 on branch 2.0.x (BUG/API: preserve non-nano in factorize/unique)"

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.

@mroeschke
Copy link
Member

Mind creating the backport PR @jbrockmendel ?

jbrockmendel added a commit to jbrockmendel/pandas that referenced this pull request Mar 15, 2023
* BUG/API: preserve non-nano in factorize/unique

* test

(cherry picked from commit 6a13450)
phofl pushed a commit that referenced this pull request Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Non-Nano datetime64/timedelta64 with non-nanosecond resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG (2.0rc0): groupby changes dtype unexpectedly from timedelta64[s] to timedelta64[ns]
4 participants