Skip to content

Commit 7080d24

Browse files
committed
add np.nan* funcs to cython_table
1 parent da9d851 commit 7080d24

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

doc/source/whatsnew/v0.24.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,7 @@ Numeric
10801080
- Bug in :meth:`DataFrame.astype` to extension dtype may raise ``AttributeError`` (:issue:`22578`)
10811081
- Bug in :class:`DataFrame` with ``timedelta64[ns]`` dtype arithmetic operations with ``ndarray`` with integer dtype incorrectly treating the narray as ``timedelta64[ns]`` dtype (:issue:`23114`)
10821082
- Bug in :meth:`Series.rpow` with object dtype ``NaN`` for ``1 ** NA`` instead of ``1`` (:issue:`22922`).
1083+
- :meth:`Series.agg` can now handle numpy NaN-aware methods like :func:`numpy.nansum` (:issue:`19629`)
10831084

10841085
Strings
10851086
^^^^^^^

pandas/core/base.py

+12
Original file line numberDiff line numberDiff line change
@@ -178,27 +178,39 @@ class SelectionMixin(object):
178178
_selection = None
179179
_internal_names = ['_cache', '__setstate__']
180180
_internal_names_set = set(_internal_names)
181+
181182
_builtin_table = OrderedDict((
182183
(builtins.sum, np.sum),
183184
(builtins.max, np.max),
184185
(builtins.min, np.min),
185186
))
187+
186188
_cython_table = OrderedDict((
187189
(builtins.sum, 'sum'),
188190
(builtins.max, 'max'),
189191
(builtins.min, 'min'),
190192
(np.all, 'all'),
191193
(np.any, 'any'),
192194
(np.sum, 'sum'),
195+
(np.nansum, 'sum'),
193196
(np.mean, 'mean'),
197+
(np.nanmean, 'mean'),
194198
(np.prod, 'prod'),
199+
(np.nanprod, 'prod'),
195200
(np.std, 'std'),
201+
(np.nanstd, 'std'),
196202
(np.var, 'var'),
203+
(np.nanvar, 'var'),
197204
(np.median, 'median'),
205+
(np.nanmedian, 'median'),
198206
(np.max, 'max'),
207+
(np.nanmax, 'max'),
199208
(np.min, 'min'),
209+
(np.nanmin, 'min'),
200210
(np.cumprod, 'cumprod'),
211+
(np.nancumprod, 'cumprod'),
201212
(np.cumsum, 'cumsum'),
213+
(np.nancumsum, 'cumsum'),
202214
))
203215

204216
@property

0 commit comments

Comments
 (0)