NVIDIA / NVIDIA/cudf

[FEA] Define `__hash__` on CategoricalDtype

Open
#14,027 1 comment 0 reactions 0 assignees View on GitHub
feature request Python
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Is your feature request related to a problem? Please describe.**
Would be nice if `hash(CategoricalDtype(...))` was supported

```
In [9]: import cudf

In [10]: import pandas

In [11]: hash(cudf.CategoricalDtype(list("abc")))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[11], line 1
----> 1 hash(cudf.CategoricalDtype(list("abc")))

TypeError: unhashable type: 'CategoricalDtype'

In [12]: hash(pandas.CategoricalDtype(list("abc")))
Out[12]: 1532899084736511412
```

**Describe the solution you'd like**
Define `__hash__` on `CategoricalDtype`

**Describe alternatives you've considered**
Custom hash based on order and categories

**Additional context**
Add any other context, code examples, or references to existing implementations about the feature request here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.