Skip to content

Commit 05fdeb3

Browse files
committed
Fixed metadata propagation in Dataframe.idxmax and Dataframe.idxmin pandas-dev#28283
1 parent bedd8f0 commit 05fdeb3

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

pandas/core/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11010,7 +11010,7 @@ def idxmin(
1101011010

1101111011
index = data._get_axis(axis)
1101211012
result = [index[i] if i >= 0 else np.nan for i in indices]
11013-
return data._constructor_sliced(result, index=data._get_agg_axis(axis))
11013+
return data._constructor_sliced(result, index=data._get_agg_axis(axis)).__finalize__(self, method="idxmin")
1101411014

1101511015
@doc(_shared_docs["idxmax"], numeric_only_default="False")
1101611016
def idxmax(
@@ -11035,7 +11035,7 @@ def idxmax(
1103511035

1103611036
index = data._get_axis(axis)
1103711037
result = [index[i] if i >= 0 else np.nan for i in indices]
11038-
return data._constructor_sliced(result, index=data._get_agg_axis(axis))
11038+
return data._constructor_sliced(result, index=data._get_agg_axis(axis)).__finalize__(self, method="idxmax")
1103911039

1104011040
def _get_agg_axis(self, axis_num: int) -> Index:
1104111041
"""

pandas/tests/generic/test_finalize.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,10 @@
227227
(pd.DataFrame, frame_data, operator.methodcaller("nunique")),
228228
),
229229
pytest.param(
230-
(pd.DataFrame, frame_data, operator.methodcaller("idxmin")),
231-
marks=not_implemented_mark,
230+
(pd.DataFrame, frame_data, operator.methodcaller("idxmin"))
232231
),
233232
pytest.param(
234-
(pd.DataFrame, frame_data, operator.methodcaller("idxmax")),
235-
marks=not_implemented_mark,
233+
(pd.DataFrame, frame_data, operator.methodcaller("idxmax"))
236234
),
237235
pytest.param(
238236
(pd.DataFrame, frame_data, operator.methodcaller("mode")),

0 commit comments

Comments
 (0)