Skip to content

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Apr 24, 2023

Adds a ArrowExtensionArray._reduce_pyarrow method that returns a pyarrow scalar and makes ArrowExtensionArray._reduce get its pyarrow scalar from that and converts it there to a python scalar.

There are situations where we want to know the type of the value returned from pyarrow reductions (e.g. #52788) and this allows us to get the pyarrow type.

This changes no functionality.

return type(self)(result)

def _reduce(self, name: str, *, skipna: bool = True, **kwargs):
def _reduce_pyarrow(self, name: str, *, skipna: bool = True, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

Can we type this out at -> pa.Scalar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's possible. I've updated.

@mroeschke mroeschke added Refactor Internal refactoring of code Arrow pyarrow functionality labels Apr 24, 2023
@mroeschke mroeschke merged commit c9dbb81 into pandas-dev:main Apr 25, 2023
@mroeschke
Copy link
Member

Thanks @topper-123

@topper-123 topper-123 deleted the reduce_pyarrow branch April 25, 2023 17:33
Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
* REF: refactor ArrowExtensionArray._reduce

* fix

* add return type to _reduce_pyarrow
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
* REF: refactor ArrowExtensionArray._reduce

* fix

* add return type to _reduce_pyarrow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arrow pyarrow functionality Refactor Internal refactoring of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants