8000 WIP: implement reductions for DatetimeArray/TimedeltaArray/PeriodArray by jbrockmendel · Pull Request #23890 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

WIP: implement reductions for DatetimeArray/TimedeltaArray/PeriodArray #23890

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
standardize signatures on Index reductions
  • Loading branch information
jbrockmendel committed Nov 28, 2018
commit febaf6731d01a3a6349d3637c0cc989eeb3c6bd7
12 changes: 8 additions & 4 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def _ndarray_values(self):
def empty(self):
return not self.size

def max(self):
def max(self, skipna=True, axis=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

In Series, these are all (self, axis=None, skipna=None, ...).

"""
Return the maximum value of the Index.

Expand Down Expand Up @@ -826,19 +826,21 @@ def max(self):
>>> idx.max()
('b', 2)
"""
nv.validate_minmax_axis(axis)
return nanops.nanmax(self.values)

def argmax(self, axis=None):
def argmax(self, skipna=True, axis=None):
"""
Return a ndarray of the maximum argument indexer.

See Also
--------
numpy.ndarray.argmax
"""
nv.validate_minmax_axis(axis)
return nanops.nanargmax(self.values)

def min(self):
def min(self, skipna=True, axis=None):
"""
Return the minimum value of the Index.

Expand Down Expand Up @@ -869,16 +871,18 @@ def min(self):
>>> idx.min()
('a', 1)
"""
nv.validate_minmax_axis(axis)
return nanops.nanmin(self.values)

def argmin(self, axis=None):
def argmin(self, skipna=True, axis=None):
"""
Return a ndarray of the minimum argument indexer.

See Also
--------
numpy.ndarray.argmin
"""
nv.validate_minmax_axis(axis)
return nanops.nanargmin(self.values)

def tolist(self):
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def tolist(self):
"""
return list(self.astype(object))

def min(self, axis=None, *args, **kwargs):
def min(self, skipna=True, axis=None, *args, **kwargs):
"""
Return the minimum value of the Index or minimum along
an axis.
Expand Down Expand Up @@ -470,7 +470,7 @@ def min(self, axis=None, *args, **kwargs):
except ValueError:
return self._na_value

def argmin(self, axis=None, *args, **kwargs):
def argmin(self, skipna=True, axis=None, *args, **kwargs):
"""
Returns the indices of the minimum values along an axis.

Expand All @@ -493,7 +493,7 @@ def argmin(self, axis=None, *args, **kwargs):
i8[mask] = np.iinfo('int64').max
return i8.argmin()

def max(self, axis=None, *args, **kwargs):
def max(self, skipna=True, axis=None, *args, **kwargs):
"""
Return the maximum value of the Index or maximum along
an axis.
Expand Down Expand Up @@ -521,7 +521,7 @@ def max(self, axis=None, *args, **kwargs):
except ValueError:
return self._na_value

def argmax(self, axis=None, *args, **kwargs):
def argmax(self, skipna=True, axis=None, *args, **kwargs):
"""
Returns the indices of the maximum values along an axis.

Expand Down
5 changes: 2 additions & 3 deletions pandas/core/indexes/range.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


class RangeIndex(Int64Index):

"""
Immutable Index implementing a monotonic integer range.

Expand Down Expand Up @@ -288,11 +287,11 @@ def _minmax(self, meth):

return self._start + self._step * no_steps

def min(self):
def min(self, skipna=True, axis=None):
"""The minimum value of the RangeIndex"""
return self._minmax('min')

def max(self):
def max(self, skipna=True, axis=None):
"""The maximum value of the RangeIndex"""
return self._minmax('max')

Expand Down
0