Skip to content
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

ENH: support argmin/max, idxmin/max with object dtype #54109

Merged
merged 1 commit into from
Jul 17, 2023

Conversation

jbrockmendel
Copy link
Member

Agreed upon in yesterday's call.

@@ -1070,27 +1071,89 @@ def test_timedelta64_analytics(self):
(Series(["foo", "foo", "bar", "bar", None, np.nan, "baz"]), TypeError),
],
)
def test_assert_idxminmax_raises(self, test_input, error_type):
def test_assert_idxminmax_empty_raises(self, test_input, error_type):
Copy link
Member

Choose a reason for hiding this comment

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

It looks like error_type can be removed from the parametrization now?

ser3 = Series(["foo", "foo", "bar", "bar", None, np.nan, "baz"])
msg = "'>' not supported between instances of 'float' and 'str'"
with pytest.raises(TypeError, match=msg):
ser3.idxmax()
Copy link
Member

Choose a reason for hiding this comment

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

So with object dtype, na-like values are not considered "missing" and rather object scalars so skipna=True has no effect here?

Copy link
Member Author

Choose a reason for hiding this comment

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

the skipping part is done after the np.argmin/np.argmax is done, so that can still raise

@mroeschke mroeschke added the Dtype Conversions Unexpected or buggy dtype conversions label Jul 13, 2023
@mroeschke mroeschke added this to the 2.1 milestone Jul 17, 2023
@mroeschke mroeschke merged commit 394af8e into pandas-dev:main Jul 17, 2023
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the enh-argmax branch July 17, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
2 participants