[FEA] Groupby support with Decimal column as key column
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
```
import cudf
from cudf.core.dtypes import Decimal64Dtype
df = cudf.DataFrame({'id': [0, 1, 2]})
df['id_dec'] = df['id'].astype(Decimal64Dtype(7,2))
#works
df.groupby('id').count()
# fails
df.groupby('id_dec').count()
```
```
---------------------------------------------------------------------------
RecursionError Traceback (most recent call last)
in
----> 1 df.groupby('id_dec').count()
/conda/lib/python3.8/site-packages/cudf/core/groupby/groupby.py in _agg_func_name_with_args(self, func_name, *args, **kwargs)
605
606 func.__name__ = func_name
--> 607 return self.agg(func)
608
609
/conda/lib/python3.8/contextlib.py in inner(*args, **kwds)
73 def inner(*args, **kwds):
74 with self._recreate_cm():
---> 75 return func(*args, **kwds)
76 return inner
77
/conda/lib/python3.8/site-packages/cudf/core/groupby/groupby.py in agg(self, func)
163 # a Float64Index, while Pandas returns an Int64Index
164 # (GH: 6945)
--> 165 result = self._groupby.aggregate(self.obj, normalized_aggs)
166
167 result = cudf.DataFrame._from_table(result)
/conda/lib/python3.8/site-packages/cudf/utils/utils.py in __get__(self, instance, cls)
276 return self
277 else:
--> 278 value = self.func(instance)
279 setattr(instance, self.func.__name__, value)
280 return value
/conda/lib/python3.8/site-packages/cudf/core/groupby/groupby.py in _groupby(self)
102 @cached_property
103 def _groupby(self):
--> 104 return libgroupby.GroupBy(self.grouping.keys, dropna=self._dropna)
105
106 @annotate("GROUPBY_AGG", domain="cudf_python")
/conda/lib/python3.8/site-packages/cudf/core/groupby/groupby.py in keys(self)
887 )
888 else:
--> 889 return cudf.core.index.as_index(
890 self._key_columns[0], name=self.names[0]
891 )
/conda/lib/python3.8/site-packages/cudf/core/index.py in as_index(arbitrary, **kwargs)
2866 elif isinstance(arbitrary, range):
2867 return RangeIndex(arbitrary, **kwargs)
-> 2868 return as_index(
2869 column.as_column(arbitrary, dtype=kwargs.get("dtype", None)), **kwargs
2870 )
... last 1 frames repeated, from the frame below ...
/conda/lib/python3.8/site-packages/cudf/core/index.py in as_index(arbitrary, **kwargs)
2866 elif isinstance(arbitrary, range):
2867 return RangeIndex(arbitrary, **kwargs)
-> 2868 return as_index(
2869 column.as_column(arbitrary, dtype=kwargs.get("dtype", None)), **kwargs
2870 )
RecursionError: maximum recursion depth exceeded in comparison
```
Contributor guide
Assessment
This issue has not been assessed yet.