Skip to content

ENH: __array_ufunc__ handle np.minimum.reduce #43923

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

Merged
merged 10 commits into from
Nov 29, 2021

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Oct 8, 2021

  • closes #xxxx
  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry

np.mimum.reduce(frame) -> return Series instead of ndarray

np.maximum.reduce(series[dt64]) -> return Timestamp instead of np.datetime64
np.maximum.reduce(series[td64]) -> return Timedelta instead of np.timedelta64
np.maximum.reduce(DTA) -> return Timestamp instead of np.datetime64
np.maximum.reduce(TDA) -> return Timedelta instead of np.timedelta64
np.maximum.reduce(DTI) -> return Timestamp instead of np.datetime64
np.maximum.reduce(TDI) -> return Timedelta instead of np.timedelta64

np.maximum.reduce(integer_array) works instead of raising NotImplementedError
np.maximum.reduce(floating_array) works instead of raising NotImplementedError
np.maximum.reduce(Series[Int]) works instead of raising NotImplementedError
np.maximum.reduce(Series[Float]) works instead of raising NotImplementedError

Ditto for np.minimum.reduce

@jreback jreback added Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Dtype Conversions Unexpected or buggy dtype conversions labels Oct 10, 2021
@jreback jreback added this to the 1.4 milestone Oct 10, 2021
if self.ndim > 1:
if isinstance(self, ABCNDFrame):
# TODO: test cases where this doesn't hold, i.e. 2D DTA/TDA
kwargs["numeric_only"] = False
Copy link
Contributor

Choose a reason for hiding this comment

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

do we normally modify the inputs?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, but that's bc the ufunc takes different kwargs than the DataFrame method

@jreback
Copy link
Contributor

jreback commented Nov 28, 2021

needs a whatsnew note

@jbrockmendel
Copy link
Member Author

needs a whatsnew note

has one

@jreback jreback merged commit 7b7fafe into pandas-dev:master Nov 29, 2021
@jbrockmendel jbrockmendel deleted the enh-ufunc-reductions branch December 13, 2021 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants