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] __contains__ not comparing int vs float values #15656

Closed
galipremsagar opened this issue May 5, 2024 · 0 comments · Fixed by #15657
Closed

[BUG] __contains__ not comparing int vs float values #15656

galipremsagar opened this issue May 5, 2024 · 0 comments · Fixed by #15657
Assignees
Labels
bug Something isn't working cudf.pandas Issues specific to cudf.pandas

Comments

@galipremsagar
Copy link
Contributor

Steps/Code to reproduce bug

In [1]: import cudf

In [2]: idx = cudf.Index([1, 2, 3])

In [3]: 1.0 in idx
Out[3]: False

In [4]: 1.0 in idx.to_pandas()
Out[4]: True

In [5]: [] in idx
Out[5]: False

In [6]: [] in idx.to_pandas()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[6], line 1
----> 1 [] in idx.to_pandas()

File /nvme/0/pgali/envs/cudfdev/lib/python3.11/site-packages/pandas/core/indexes/base.py:5358, in Index.__contains__(self, key)
   5323 def __contains__(self, key: Any) -> bool:
   5324     """
   5325     Return a boolean indicating whether the provided key is in the index.
   5326 
   (...)
   5356     False
   5357     """
-> 5358     hash(key)
   5359     try:
   5360         return key in self._engine

TypeError: unhashable type: 'list'
@galipremsagar galipremsagar added bug Something isn't working cudf.pandas Issues specific to cudf.pandas labels May 5, 2024
@galipremsagar galipremsagar added this to the cudf.pandas API coverage milestone May 5, 2024
@galipremsagar galipremsagar self-assigned this May 5, 2024
rapids-bot bot pushed a commit that referenced this issue May 6, 2024
…#15657)

Fixes: #15656

This PR:

- [x] Raises error for non-hashable values passed to `__contains__`
- [x] Fixes comparison of float values with int columns

Forks out of #14534

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

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

URL: #15657
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cudf.pandas Issues specific to cudf.pandas
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant