Skip to content

Conversation

jbrockmendel
Copy link
Member

@mroeschke might have an opinion on a better place to put the hard-coded (completely arbitrary) 1_000 value.

>>> nanops.nanmean(s.values)
np.float64(1.5)
"""
if values.dtype == object and len(values) > 1_000 and mask is None:
Copy link
Member

Choose a reason for hiding this comment

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

Can we just not infer_dtype(values) for object dtype to raise early if the inferred type are strings?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. infer_dtype is a pattern im trying to move us away from, 2) that would still require a full pass through the data, 3) that would for strings but not hypothetical other cases

Copy link
Member

Choose a reason for hiding this comment

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

OK sure thing. Should the 5 below then match the 1000 above then for consistency?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, will update

@mroeschke mroeschke added Error Reporting Incorrect or improved errors from pandas Reduction Operations sum, mean, min, max, etc. labels Sep 8, 2025
@mroeschke mroeschke added this to the 3.0 milestone Sep 15, 2025
@mroeschke mroeschke merged commit 0c87e2d into pandas-dev:main Sep 15, 2025
38 checks passed
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the fail-fast branch September 15, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Error Reporting Incorrect or improved errors from pandas Reduction Operations sum, mean, min, max, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PERF: mean method works too long with object type

2 participants