Part of #46560
For Series and SeriesGroupBy ops (and perhaps others like resample, rolling, window, expanding, ewm), there is an inconsistency when numeric_only is passed to ops that have it as an argument:
ser = pd.Series([1, 2, 3])
print(ser.mean(numeric_only=True))
# Raises `NotImplementedError: Series.mean does not implement numeric_only.`
print(ser.mean(numeric_only=False))
# 2.0
print(ser.groupby([0, 0, 1]).mean(numeric_only=True))
# 0 1.5
# 1 3.0
# dtype: float64
print(ser.groupby([0, 0, 1]).mean(numeric_only=False))
# 0 1.5
# 1 3.0
# dtype: float64
I see three possible options:
I am in favor of 1 - I view passing in numeric_only=True
as erroneous; it doesn't make sense to request this from a Series even if it is a no-op. On the other hand, I view passing in numeric_only=False
as "requesting nothing", though perhaps it is slightly odd. Option 1 would also allow the default to be False across all ops (in pandas 2.0).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4