-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Fix EX01 in pandas.DataFrame.idxmax #32551
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 1 commit
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 |
---|---|---|
|
@@ -8029,6 +8029,35 @@ def idxmax(self, axis=0, skipna=True) -> Series: | |
Notes | ||
----- | ||
This method is the DataFrame version of ``ndarray.argmax``. | ||
|
||
Examples | ||
-------- | ||
Consider dataset containing food consumption in Argentina. | ||
|
||
>>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48], | ||
... 'co2_emission': [37.2, 19.66, 1712]}, | ||
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.
(this will have to change in the other parts too) |
||
... index=['Pork', 'Wheat Products', 'Beef']) | ||
|
||
>>> df | ||
consumption co2_emission | ||
Pork 10.51 37.20 | ||
Wheat Products 103.11 19.66 | ||
Beef 55.48 1712.00 | ||
|
||
By default, it returns index for the maximum value in each columns. | ||
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.
|
||
|
||
>>> df.idxmax() | ||
consumption Wheat Products | ||
co2_emission Beef | ||
dtype: object | ||
|
||
To return index for the maximum value in each rows, use ``axis="columns"``. | ||
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.
|
||
|
||
>>> df.idxmax(axis="columns") | ||
Pork co2_emission | ||
Wheat Products consumption | ||
Beef co2_emission | ||
dtype: object | ||
""" | ||
axis = self._get_axis_number(axis) | ||
indices = nanops.nanargmax(self.values, axis=axis, 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.