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

feat: consistently return Python scalars from Series reductions for PyArrow #1471

Merged
merged 6 commits into from
Nov 30, 2024

Conversation

MarcoGorelli
Copy link
Member

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

  • Related issue #<issue number>
  • Closes #<issue number>

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below

@github-actions github-actions bot added the enhancement New feature or request label Nov 30, 2024
Copy link
Member

@FBruzzesi FBruzzesi left a comment

Choose a reason for hiding this comment

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

Diff looks good! I have a couple of comments πŸ˜‡

Comment on lines 35 to 38
def maybe_extract_py_scalar(value: Any, return_py_scalar: bool) -> Any: # noqa: FBT001
if return_py_scalar:
return to_py_scalar(value)
return value
Copy link
Member

Choose a reason for hiding this comment

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

Should we target this to arrow specifically instead of using the more generic to_py_scalar?

narwhals/_arrow/dataframe.py Outdated Show resolved Hide resolved
Comment on lines +229 to +233
extra_kwargs = (
{"_return_py_scalar": False}
if returns_scalar and expr._implementation is Implementation.PYARROW
else {}
)
Copy link
Member

Choose a reason for hiding this comment

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

Neat! ✨

Co-authored-by: Francesco Bruzzesi <[email protected]>
@MarcoGorelli MarcoGorelli marked this pull request as draft November 30, 2024 14:01
@MarcoGorelli MarcoGorelli marked this pull request as ready for review November 30, 2024 15:41
@MarcoGorelli
Copy link
Member Author

thanks @FBruzzesi ! any other comments?

@FBruzzesi
Copy link
Member

thanks @FBruzzesi ! any other comments?

I am from mobile but it seems good! Thanks for addressing both points :)

@MarcoGorelli MarcoGorelli merged commit bfbc34d into narwhals-dev:main Nov 30, 2024
24 checks passed
@FBruzzesi FBruzzesi mentioned this pull request Dec 1, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants