Skip to content

Commit

Permalink
Revert "Fixed metadata propagation in Dataframe.idxmax and Dataframe.…
Browse files Browse the repository at this point in the history
…idxmin #… (pandas-dev#47821)"

This reverts commit b0a51fe.
  • Loading branch information
dannyi96 committed Jul 26, 2022
1 parent f11a5d2 commit 6890117
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 2 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -11010,8 +11010,7 @@ def idxmin(

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

@doc(_shared_docs["idxmax"], numeric_only_default="False")
def idxmax(
Expand All @@ -11036,8 +11035,7 @@ def idxmax(

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

def _get_agg_axis(self, axis_num: int) -> Index:
"""
Expand Down
14 changes: 11 additions & 3 deletions pandas/tests/generic/test_finalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,17 @@
pytest.param(
(pd.DataFrame, frame_data, operator.methodcaller("nunique")),
),
(pd.DataFrame, frame_data, operator.methodcaller("idxmin")),
(pd.DataFrame, frame_data, operator.methodcaller("idxmax")),
(pd.DataFrame, frame_data, operator.methodcaller("mode")),
pytest.param(
(pd.DataFrame, frame_data, operator.methodcaller("idxmin")),
marks=not_implemented_mark,
),
pytest.param(
(pd.DataFrame, frame_data, operator.methodcaller("idxmax")),
marks=not_implemented_mark,
),
pytest.param(
(pd.DataFrame, frame_data, operator.methodcaller("mode")),
),
pytest.param(
(pd.Series, [0], operator.methodcaller("mode")),
marks=not_implemented_mark,
Expand Down

0 comments on commit 6890117

Please sign in to comment.