[BUG] cudf.cut does not accept sequence of scalars
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
**Describe the bug**
working with `import cudf as pd`
**Steps/Code to reproduce bug**
```
In [1]: import cudf as pd
In [2]: pd.__version__
Out[2]: '23.02.00'
In [3]: import numpy as np
In [4]: df = pd.DataFrame({'a': range(100)})
In [5]: pd.cut(df.a, bins=np.linspace(0, 100, num=6))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
----> 1 pd.cut(df.a, bins=np.linspace(0, 100, num=6))
/opt/conda/envs/rapids/lib/python3.8/site-packages/cudf/core/cut.py in cut(x, bins, right, labels, retbins, precision, include_lowest, duplicates, ordered)
168 mn = min(x)
169 mx = max(x)
--> 170 bins = np.linspace(mn, mx, bins + 1, endpoint=True)
171 adj = (mx - mn) * 0.001
172 if right:
/opt/conda/envs/rapids/lib/python3.8/site-packages/numpy/core/overrides.py in linspace(*args, **kwargs)
/opt/conda/envs/rapids/lib/python3.8/site-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
118
119 """
--> 120 num = operator.index(num)
121 if num < 0:
122 raise ValueError("Number of samples, %s, must be non-negative." % num)
TypeError: only integer scalar arrays can be converted to a scalar index
In [6]: import pandas
In [7]: pandas.cut(df.to_pandas().a, bins=np.linspace(0, 100, num=6))
Out[7]:
0 NaN
1 (0.0, 20.0]
2 (0.0, 20.0]
3 (0.0, 20.0]
4 (0.0, 20.0]
...
95 (80.0, 100.0]
96 (80.0, 100.0]
97 (80.0, 100.0]
98 (80.0, 100.0]
99 (80.0, 100.0]
Name: a, Length: 100, dtype: category
Categories (5, interval[float64, right]): [(0.0, 20.0] < (20.0, 40.0] < (40.0, 60.0] <
(60.0, 80.0] < (80.0, 100.0]]
```
**Additional context**
https://docs.rapids.ai/api/cudf/stable/api_docs/api/cudf.cut.html

Contributor guide
Assessment
This issue has not been assessed yet.