Skip to content

API: .argmax should be positional, not an alias for idxmax #16830

Closed
@TomAugspurger

Description

@TomAugspurger

In #6214 it was reported that argmax changed (I think since Series didn't subclass ndarray anymore). It's sometimes useful to get the index position of the max, so it'd be nice if .argmax did that, leaving idxmax to always be label-based.

In [1]: import pandas as pd
pd.Ser
In [2]: s = pd.Series([1, 2, 3, 0], index=['a', 'b', 'c', 'd'])

In [3]: s.idxmax()
Out[3]: 'c'

In [4]: s.argmax()
Out[4]: 'c'

I would expect Out[4] to be 2. The current workaround is np.argmax(x), which is OK, but doesn't generalize to DataFrames well.

We could deprecate .argmax in 0.21, pointing users to .idxmax. Then later we can change .argmax to be always be positional.


Update: We've deprecated .argmax/min. Need to change the behavior next.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignDeprecateFunctionality to remove in pandasIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions