@@ -2302,8 +2302,7 @@ def first(self, numeric_only: bool = False, min_count: int = -1):
2302
2302
Parameters
2303
2303
----------
2304
2304
numeric_only : bool, default False
2305
- Include only float, int, boolean columns. If None, will attempt to use
2306
- everything, then use only numeric data.
2305
+ Include only float, int, boolean columns.
2307
2306
min_count : int, default -1
2308
2307
The required number of valid values to perform the operation. If fewer
2309
2308
than ``min_count`` non-NA values are present the result will be NA.
@@ -2323,8 +2322,20 @@ def first(self, numeric_only: bool = False, min_count: int = -1):
2323
2322
2324
2323
Examples
2325
2324
--------
2326
- >>> df = pd.DataFrame(dict(A=[1, 1, 3], B=[None, 5, 6], C=[1, 2, 3]))
2325
+ >>> df = pd.DataFrame(dict(A=[1, 1, 3], B=[None, 5, 6], C=[1, 2, 3],
2326
+ ... D=['3/11/2000', '3/12/2000', '3/13/2000']))
2327
+ >>> df['D'] = pd.to_datetime(df['D'])
2327
2328
>>> df.groupby("A").first()
2329
+ B C D
2330
+ A
2331
+ 1 5.0 1 2000-03-11
2332
+ 3 6.0 3 2000-03-13
2333
+ >>> df.groupby("A").first(min_count=2)
2334
+ B C D
2335
+ A
2336
+ 1 NaN 1.0 2000-03-11
2337
+ 3 NaN NaN NaT
2338
+ >>> df.groupby("A").first(numeric_only=True)
2328
2339
B C
2329
2340
A
2330
2341
1 5.0 1
0 commit comments