Skip to content

Commit 361fa48

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

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
@@ -2235,8 +2235,37 @@ def max(
22352235
)
22362236

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

0 commit comments

Comments
 (0)