Skip to content

Commit f93ea41

Browse files
committed
DOC: Clarify groupby.first does not use nulls
1 parent 53b3dd5 commit f93ea41

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
@@ -2225,8 +2225,37 @@ def max(
22252225
)
22262226

22272227
@final
2228-
@doc(_groupby_agg_method_template, fname="first", no=False, mc=-1)
2228+
@Substitution(name="groupby")
2229+
@Appender(_common_see_also)
22292230
def first(self, numeric_only: bool = False, min_count: int = -1):
2231+
"""
2232+
Compute the first non-null entry of each column.
2233+
2234+
Parameters
2235+
----------
2236+
numeric_only : bool, default False
2237+
Include only float, int, boolean columns. If None, will attempt to use
2238+
everything, then use only numeric data.
2239+
min_count : int, default -1
2240+
The required number of valid values to perform the operation. If fewer
2241+
than ``min_count`` non-NA values are present the result will be NA.
2242+
2243+
Returns
2244+
-------
2245+
Series or DataFrame
2246+
First not non-null of values within each group.
2247+
2248+
Examples
2249+
--------
2250+
>>> df = pd.DataFrame(dict(A=[1, 1, 3], B=[None, 5, 6], C=[1, 2, 3]))
2251+
>>> df.groupby("A").first()
2252+
B C
2253+
A
2254+
1 5.0 1
2255+
3 6.0 3
2256+
2257+
"""
2258+
22302259
def first_compat(obj: NDFrameT, axis: int = 0):
22312260
def first(x: Series):
22322261
"""Helper function for first item that isn't NA."""

0 commit comments

Comments
 (0)