Skip to content

Commit 6947770

Browse files
committed
DOC: Clarify groupby.last does not use nulls
1 parent f93ea41 commit 6947770

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

pandas/core/groupby/groupby.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -2279,8 +2279,37 @@ def first(x: Series):
22792279
)
22802280

22812281
@final
2282-
@doc(_groupby_agg_method_template, fname="last", no=False, mc=-1)
2282+
@Substitution(name="groupby")
2283+
@Appender(_common_see_also)
22832284
def last(self, numeric_only: bool = False, min_count: int = -1):
2285+
"""
2286+
Compute the last non-null entry of each column.
2287+
2288+
Parameters
2289+
----------
2290+
numeric_only : bool, default False
2291+
Include only float, int, boolean columns. If None, will attempt to use
2292+
everything, then use only numeric data.
2293+
min_count : int, default -1
2294+
The required number of valid values to perform the operation. If fewer
2295+
than ``min_count`` non-NA values are present the result will be NA.
2296+
2297+
Returns
2298+
-------
2299+
Series or DataFrame
2300+
First not non-null of values within each group.
2301+
2302+
Examples
2303+
--------
2304+
>>> df = pd.DataFrame(dict(A=[1, 1, 3], B=[5, None, 6], C=[1, 2, 3]))
2305+
>>> df.groupby("A").first()
2306+
B C
2307+
A
2308+
1 5.0 2
2309+
3 6.0 3
2310+
2311+
"""
2312+
22842313
def last_compat(obj: NDFrameT, axis: int = 0):
22852314
def last(x: Series):
22862315
"""Helper function for last item that isn't NA."""

0 commit comments

Comments
 (0)