Skip to content

Commit eb9dd2b

Browse files
committed
Fix docstring and failing future string test
1 parent 9add8bb commit eb9dd2b

File tree

2 files changed

+62
-6
lines changed

2 files changed

+62
-6
lines changed

pandas/core/groupby/groupby.py

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,61 @@ class providing the base-class of operations.
214214
{example}
215215
"""
216216

217+
_groupby_agg_method_skipna_engine_template = """
218+
Compute {fname} of group values.
219+
220+
Parameters
221+
----------
222+
numeric_only : bool, default {no}
223+
Include only float, int, boolean columns.
224+
225+
.. versionchanged:: 2.0.0
226+
227+
numeric_only no longer accepts ``None``.
228+
229+
min_count : int, default {mc}
230+
The required number of valid values to perform the operation. If fewer
231+
than ``min_count`` non-NA values are present the result will be NA.
232+
233+
skipna : bool, default {s}
234+
Exclude NA/null values. If the entire group is NA and ``skipna`` is
235+
``True``, the result will be NA.
236+
237+
.. versionchanged:: 3.0.0
238+
239+
engine : str, default None {e}
240+
* ``'cython'`` : Runs rolling apply through C-extensions from cython.
241+
* ``'numba'`` : Runs rolling apply through JIT compiled code from numba.
242+
Only available when ``raw`` is set to ``True``.
243+
* ``None`` : Defaults to ``'cython'`` or globally setting ``compute.use_numba``
244+
245+
engine_kwargs : dict, default None {ek}
246+
* For ``'cython'`` engine, there are no accepted ``engine_kwargs``
247+
* For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
248+
and ``parallel`` dictionary keys. The values must either be ``True`` or
249+
``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
250+
``{{'nopython': True, 'nogil': False, 'parallel': False}}`` and will be
251+
applied to both the ``func`` and the ``apply`` groupby aggregation.
252+
253+
Returns
254+
-------
255+
Series or DataFrame
256+
Computed {fname} of values within each group.
257+
258+
See Also
259+
--------
260+
SeriesGroupBy.min : Return the min of the group values.
261+
DataFrameGroupBy.min : Return the min of the group values.
262+
SeriesGroupBy.max : Return the max of the group values.
263+
DataFrameGroupBy.max : Return the max of the group values.
264+
SeriesGroupBy.sum : Return the sum of the group values.
265+
DataFrameGroupBy.sum : Return the sum of the group values.
266+
267+
Examples
268+
--------
269+
{example}
270+
"""
271+
217272
_pipe_template = """
218273
Apply a ``func`` with arguments to this %(klass)s object and return its result.
219274
@@ -2108,10 +2163,10 @@ def mean(
21082163
numeric_only no longer accepts ``None`` and defaults to ``False``.
21092164
21102165
skipna : bool, default True
2111-
Exclude NA/null values. If the entire group is NA and ``skipna`` is
2112-
True, the result will be NA.
2166+
Exclude NA/null values. If an entire row/column is NA, the result
2167+
will be NA.
21132168
2114-
-- versionadded:: 3.0.0
2169+
.. versionadded:: 3.0.0
21152170
21162171
engine : str, default None
21172172
* ``'cython'`` : Runs the operation through C-extensions from cython.
@@ -2828,10 +2883,11 @@ def size(self) -> DataFrame | Series:
28282883

28292884
@final
28302885
@doc(
2831-
_groupby_agg_method_engine_template,
2886+
_groupby_agg_method_skipna_engine_template,
28322887
fname="sum",
28332888
no=False,
28342889
mc=0,
2890+
s=True,
28352891
e=None,
28362892
ek=None,
28372893
example=dedent(

pandas/tests/groupby/test_reductions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,11 @@ def test_sum_skipna_object(skipna):
505505
if skipna:
506506
expected = Series(
507507
["aegi", "bdfhj"], index=pd.Index(["A", "B"], name="cat"), name="val"
508-
)
508+
).astype(object)
509509
else:
510510
expected = Series(
511511
[np.nan, "bdfhj"], index=pd.Index(["A", "B"], name="cat"), name="val"
512-
)
512+
).astype(object)
513513
result = df.groupby("cat")["val"].sum(skipna=skipna)
514514
tm.assert_series_equal(result, expected)
515515

0 commit comments

Comments
 (0)