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

REF: Remove **kwargs from to_pandas, raise if nullable is not implemented #14438

Merged
merged 14 commits into from
Nov 27, 2023

Conversation

mroeschke
Copy link
Contributor

Description

  • Remove unnecessary **kwargs from signature
  • Typing and improve error message if nullable is not implemented

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@mroeschke mroeschke added Python Affects Python cuDF API. improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Nov 17, 2023
@mroeschke mroeschke requested a review from a team as a code owner November 17, 2023 00:09
@@ -850,7 +850,7 @@ def notna(self):
"""
raise NotImplementedError

def to_pandas(self, nullable=False):
def to_pandas(self, nullable: bool = False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I think we should make all of these arguments keyword-only

def to_pandas(self, *, nullable: bool = False):
  ...

Rationale: API safety in the case when one can pass more than just nullable as an argument. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Does that mean I should label this PR as breaking?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably an API break, yes.

python/cudf/cudf/core/column/column.py Show resolved Hide resolved
@wence- wence- added breaking Breaking change and removed non-breaking Non-breaking change labels Nov 20, 2023
Comment on lines +238 to +245
if isinstance(cudf_val, cudf.DataFrame):
pd_data = {
col: maybe_return_nullable_pd_obj(series)
for col, series in cudf_val.items()
}
pd_value = pd.DataFrame(pd_data)
else:
pd_value = maybe_return_nullable_pd_obj(cudf_val)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just handling that nullable=True was previously silently ignored for to_pandas calls that didn't support it, and now it is loud?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct!

@wence-
Copy link
Contributor

wence- commented Nov 21, 2023

One test test_list_to_pandas_nullable_true still needs handling but otherwise looks good to go.

@mroeschke mroeschke requested a review from a team as a code owner November 23, 2023 00:40
@mroeschke
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit 854f4e4 into rapidsai:branch-24.02 Nov 27, 2023
67 checks passed
@mroeschke mroeschke deleted the ref/to_pandas branch November 27, 2023 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking change improvement Improvement / enhancement to an existing function Python Affects Python cuDF API.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants