Skip to content
Merged
8 changes: 6 additions & 2 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def argsort(
mask=np.asarray(self.isna()),
)

def argmin(self):
def argmin(self, axis=None, skipna: bool = True):
Copy link
Member

Choose a reason for hiding this comment

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

The axis keyword shouldn't be added, since it's being ignored. It can be accepted through args/kwargs, and then validated with our numpy compat (+ tests for the numpy compat)

"""
Return the index of minimum value.

Expand All @@ -606,9 +606,11 @@ def argmin(self):
--------
ExtensionArray.argmax
"""
if not skipna:
raise NotImplementedError
return nargminmax(self, "argmin")

def argmax(self):
def argmax(self, axis=None, skipna: bool = True):
"""
Return the index of maximum value.

Expand All @@ -623,6 +625,8 @@ def argmax(self):
--------
ExtensionArray.argmin
"""
if not skipna:
raise NotImplementedError
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a test that hits this (and argmin)

return nargminmax(self, "argmax")

def fillna(self, value=None, method=None, limit=None):
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/groupby/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,16 @@ def test_idxmin_idxmax_returns_int_types(func, values):
}
)
df["c_date"] = pd.to_datetime(df["c_date"])
df["c_date_tz"] = df["c_date"].dt.tz_localize("US/Pacific")
df["c_timedelta"] = df["c_date"] - df["c_date"].iloc[0]
df["c_period"] = df["c_date"].dt.to_period("W")

result = getattr(df.groupby("name"), func)()

expected = DataFrame(values, index=Index(["A", "B"], name="name"))
expected["c_date_tz"] = expected["c_date"]
expected["c_timedelta"] = expected["c_date"]
expected["c_period"] = expected["c_date"]

tm.assert_frame_equal(result, expected)

Expand Down