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

TST: Avoid hashing np.timedelta64 without unit #60416

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

mroeschke
Copy link
Member

Avoids

____________________ TestValueCounts.test_value_counts_nat _____________________
[gw3] linux -- Python 3.13.0 /opt/hostedtoolcache/Python/3.13.0/x64/bin/python

self = <pandas.tests.test_algos.TestValueCounts object at 0x7f7c3f35dd20>

    def test_value_counts_nat(self):
        td = Series([np.timedelta64(10000), NaT], dtype="timedelta64[ns]")
        dt = to_datetime(["NaT", "2014-01-01"])
    
        for ser in [td, dt]:
            vc = algos.value_counts_internal(ser)
            vc_with_na = algos.value_counts_internal(ser, dropna=False)
            assert len(vc) == 1
            assert len(vc_with_na) == 2
    
        exp_dt = Series({Timestamp("2014-01-01 00:00:00"): 1}, name="count")
        result_dt = algos.value_counts_internal(dt)
        tm.assert_series_equal(result_dt, exp_dt)
    
>       exp_td = Series({np.timedelta64(10000): 1}, name="count")
E       ValueError: Can't hash generic timedelta64

pandas/tests/test_algos.py:1257: ValueError

@mroeschke mroeschke added Testing pandas testing functions or related to the test suite Compat pandas objects compatability with Numpy or Python functions labels Nov 25, 2024
@mroeschke mroeschke added this to the 2.3 milestone Nov 25, 2024
@mroeschke mroeschke merged commit 0b6cece into pandas-dev:main Nov 25, 2024
55 checks passed
@mroeschke mroeschke deleted the fix/test_value_counts_nat branch November 25, 2024 19:35
Copy link

lumberbot-app bot commented Nov 25, 2024

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.3.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 0b6cece3acda1ae6e4f582d8276851b02aeac1ea
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #60416: TST: Avoid hashing np.timedelta64 without unit'
  1. Push to a named branch:
git push YOURFORK 2.3.x:auto-backport-of-pr-60416-on-2.3.x
  1. Create a PR against branch 2.3.x, I would have named this PR:

"Backport PR #60416 on branch 2.3.x (TST: Avoid hashing np.timedelta64 without unit)"

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 added a commit to mroeschke/pandas that referenced this pull request Nov 25, 2024
mroeschke added a commit that referenced this pull request Nov 25, 2024
… without unit) (#60418)

Backport PR #60416: TST: Avoid hashing np.timedelta64 without unit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant