Skip to content

Commit e2b56cd

Browse files
committed
DOC: Clarify groupby.last does not use nulls
1 parent 361fa48 commit e2b56cd

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

pandas/core/groupby/groupby.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2289,8 +2289,37 @@ def first(x: Series):
22892289
)
22902290

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

0 commit comments

Comments
 (0)