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

[FEA] Support casting to DecimalDtypes in cuDF #7440

Closed
ChrisJar opened this issue Feb 24, 2021 · 0 comments · Fixed by #7691
Closed

[FEA] Support casting to DecimalDtypes in cuDF #7440

ChrisJar opened this issue Feb 24, 2021 · 0 comments · Fixed by #7691
Assignees
Labels
feature request New feature or request Python Affects Python cuDF API.

Comments

@ChrisJar
Copy link
Contributor

ChrisJar commented Feb 24, 2021

Is your feature request related to a problem? Please describe.
Now that cuDF supports decimal columns it would be great to be able to cast to DecimalDtype from float or int datatypes.

For example:

import cudf
from cudf.core.dtypes import Decimal64Dtype

df = cudf.DataFrame({"a":[0.51,1.51,2.51]}, dtype="float64")
df.astype(Decimal64Dtype(7,2))

This currently throws:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/u00u7rh1e72hXfsipJ357/miniconda3/envs/rapids-gpu-bdb/lib/python3.7/site-packages/cudf/core/dataframe.py", line 1163, in astype
    dtype=dtype, **kwargs
  File "/home/u00u7rh1e72hXfsipJ357/miniconda3/envs/rapids-gpu-bdb/lib/python3.7/site-packages/cudf/core/column/column.py", line 1018, in astype
    elif np.issubdtype(dtype, np.datetime64):
  File "/home/u00u7rh1e72hXfsipJ357/miniconda3/envs/rapids-gpu-bdb/lib/python3.7/site-packages/numpy/core/numerictypes.py", line 388, in issubdtype
    arg1 = dtype(arg1).type
TypeError: Cannot interpret 'Decimal64Dtype(precision=7, scale=2)' as a data type

Describe the solution you'd like
I would like to be able to convert float or int columns to decimal columns with the specified scale and precision

Describe alternatives you've considered
I've also found that:

 df = cudf.DataFrame({"a":[0.51,1.51,2.51]}, dtype=Decimal64Dtype(7,2))

throws the same error

@ChrisJar ChrisJar added Needs Triage Need team to review and classify feature request New feature or request labels Feb 24, 2021
@kkraus14 kkraus14 added Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify labels Feb 25, 2021
rapids-bot bot pushed a commit that referenced this issue Mar 10, 2021
This implements typecasting between `decimal` and `float` types.

Addresses half of #7440

Authors:
  - @ChrisJar

Approvers:
  - Ram (Ramakrishna Prabhu) (@rgsl888prabhu)
  - Ashwin Srinath (@shwina)

URL: #7450
@isVoid isVoid assigned isVoid and unassigned isVoid Mar 24, 2021
hyperbolic2346 pushed a commit to hyperbolic2346/cudf that referenced this issue Mar 25, 2021
This implements typecasting between `decimal` and `float` types.

Addresses half of rapidsai#7440

Authors:
  - @ChrisJar

Approvers:
  - Ram (Ramakrishna Prabhu) (@rgsl888prabhu)
  - Ashwin Srinath (@shwina)

URL: rapidsai#7450
rapids-bot bot pushed a commit that referenced this issue Mar 30, 2021
This enables type conversions between `decimal` types and `int` types.

Closes #7440

Authors:
  - @ChrisJar

Approvers:
  - GALI PREM SAGAR (@galipremsagar)

URL: #7691
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants