Thanks to visit codestin.com
Credit goes to github.com

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.

@@ -693,6 +693,10 @@ def nanmean(
>>> 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
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