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] Define DataFrame.__round__ for compat with round built-in function #14083

Closed
mroeschke opened this issue Sep 12, 2023 · 1 comment · Fixed by #14099
Closed

[FEA] Define DataFrame.__round__ for compat with round built-in function #14083

mroeschke opened this issue Sep 12, 2023 · 1 comment · Fixed by #14099
Assignees
Labels
feature request New feature or request Python Affects Python cuDF API.

Comments

@mroeschke
Copy link
Contributor

Is your feature request related to a problem? Please describe.

In [1]: import cudf

In [3]: round(cudf.DataFrame({"col1": [1.123, 2.123, 3.123], "col2": [1.234, 2.234, 3.234]}))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[3], line 1
----> 1 round(cudf.DataFrame({"col1": [1.123, 2.123, 3.123], "col2": [1.234, 2.234, 3.234]}))

TypeError: type DataFrame doesn't define __round__ method

In [4]: import pandas as pd

In [5]: round(pd.DataFrame({"col1": [1.123, 2.123, 3.123], "col2": [1.234, 2.234, 3.234]}))
Out[5]: 
   col1  col2
0   1.0   1.0
1   2.0   2.0
2   3.0   3.0

Describe the solution you'd like
I suppose __round__ could dispatch to DataFrame.round

Describe alternatives you've considered
Just call DataFrame.round

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

@mroeschke mroeschke added feature request New feature or request Python Affects Python cuDF API. labels Sep 12, 2023
@galipremsagar galipremsagar self-assigned this Sep 12, 2023
@bdice
Copy link
Contributor

bdice commented Sep 13, 2023

Related: #10177

rapids-bot bot pushed a commit that referenced this issue Sep 13, 2023
Fixes: #14083 

This PR fixes builtin function `round` call on `DataFrame` & `Series` to work by implementing `__round__` method.

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

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #14099
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