-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Fix errors in pandas.Series.argmin #32286
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
Changes from 15 commits
b75fddc
827db07
ef13499
ae050f7
353ce65
3acc9dd
a516ee6
2bdd088
4de38a7
1714e12
a2696a9
7f055ba
a75a04a
c89126a
04c197a
ed7a161
183833a
1699089
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -927,16 +927,19 @@ def max(self, axis=None, skipna=True, *args, **kwargs): | |||||
nv.validate_max(args, kwargs) | ||||||
return nanops.nanmax(self._values, skipna=skipna) | ||||||
|
||||||
@doc( | ||||||
op="max", oppose="min", value="largest", | ||||||
) | ||||||
def argmax(self, axis=None, skipna=True, *args, **kwargs): | ||||||
""" | ||||||
Return int position of the largest value in the Series. | ||||||
Return int position of the {value} value in the Series. | ||||||
|
||||||
If the maximum is achieved in multiple locations, | ||||||
If the {op}imum is achieved in multiple locations, | ||||||
the first row position is returned. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
axis : {None} | ||||||
axis : {{None}} | ||||||
Dummy argument for consistency with Series. | ||||||
skipna : bool, default True | ||||||
Exclude NA/null values when showing the result. | ||||||
|
@@ -946,21 +949,22 @@ def argmax(self, axis=None, skipna=True, *args, **kwargs): | |||||
Returns | ||||||
------- | ||||||
int | ||||||
Row position of the maximum values. | ||||||
Row position of the {op}imum value. | ||||||
|
||||||
See Also | ||||||
-------- | ||||||
numpy.ndarray.argmax : Equivalent method for numpy arrays. | ||||||
Series.argmin : Similar method, but returning the minimum. | ||||||
Series.argmax : Return position of the maximum value. | ||||||
Series.argmin : Return position of the minimum value. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're not finally using oppose. I think you can replace those two lines by this, and we don't need to repeat the same page in this case. Or you can simply remove the oppose parameter of
Suggested change
|
||||||
numpy.ndarray.arg{op} : Equivalent method for numpy arrays. | ||||||
Series.idxmax : Return index label of the maximum values. | ||||||
Series.idxmin : Return index label of the minimum values. | ||||||
|
||||||
Examples | ||||||
-------- | ||||||
Consider dataset containing cereal calories | ||||||
|
||||||
>>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, | ||||||
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) | ||||||
>>> s = pd.Series({{'Corn Flakes': 100.0, 'Almond Delight': 110.0, | ||||||
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}}) | ||||||
>>> s | ||||||
Corn Flakes 100.0 | ||||||
Almond Delight 110.0 | ||||||
|
@@ -970,8 +974,11 @@ def argmax(self, axis=None, skipna=True, *args, **kwargs): | |||||
|
||||||
>>> s.argmax() | ||||||
2 | ||||||
>>> s.argmin() | ||||||
0 | ||||||
|
||||||
The maximum cereal calories is in the third element, | ||||||
The maximum cereal calories is the third element and | ||||||
the minimum cereal calories is the first element, | ||||||
since series is zero-indexed. | ||||||
""" | ||||||
nv.validate_minmax_axis(axis) | ||||||
|
@@ -1019,25 +1026,10 @@ def min(self, axis=None, skipna=True, *args, **kwargs): | |||||
nv.validate_min(args, kwargs) | ||||||
return nanops.nanmin(self._values, skipna=skipna) | ||||||
|
||||||
@doc( | ||||||
argmax, op="min", oppose="max", value="smallest", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as before about being a one-liner. |
||||||
) | ||||||
def argmin(self, axis=None, skipna=True, *args, **kwargs): | ||||||
""" | ||||||
Return a ndarray of the minimum argument indexer. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
axis : {None} | ||||||
Dummy argument for consistency with Series. | ||||||
skipna : bool, default True | ||||||
|
||||||
Returns | ||||||
------- | ||||||
numpy.ndarray | ||||||
|
||||||
See Also | ||||||
-------- | ||||||
numpy.ndarray.argmin : Return indices of the minimum values along | ||||||
the given axis. | ||||||
""" | ||||||
nv.validate_minmax_axis(axis) | ||||||
nv.validate_argmax_with_skipna(skipna, args, kwargs) | ||||||
return nanops.nanargmin(self._values, skipna=skipna) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is from black, but I guess you can leave the decorator in a single line, and black will respect it.