Skip to content

Commit 5396a3d

Browse files
committed
fixup! DOC: add examples to groupby.first
1 parent 327fe4b commit 5396a3d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

pandas/core/groupby/groupby.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -2322,24 +2322,24 @@ def first(self, numeric_only: bool = False, min_count: int = -1):
23222322
23232323
Examples
23242324
--------
2325-
>>> df = pd.DataFrame(dict(A=[1, 1, 3], B=[2, 2, None],
2326-
... C=['3/11/2000', '3/12/2000', '3/13/2000']))
2327-
>>> df['C'] = pd.to_datetime(df['C'])
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'])
23282328
>>> df.groupby("A").first()
2329-
B C
2329+
B C D
23302330
A
2331-
1 2.0 2000-03-11
2332-
3 NaN 2000-03-13
2331+
1 5.0 1 2000-03-11
2332+
3 6.0 3 2000-03-13
23332333
>>> df.groupby("A").first(min_count=2)
2334-
B C
2334+
B C D
23352335
A
2336-
1 2.0 2000-03-11
2337-
3 NaN NaT
2336+
1 NaN 1.0 2000-03-11
2337+
3 NaN NaN NaT
23382338
>>> df.groupby("A").first(numeric_only=True)
2339-
B
2339+
B C
23402340
A
2341-
1 2.0
2342-
3 NaN
2341+
1 5.0 1
2342+
3 6.0 3
23432343
"""
23442344

23452345
def first_compat(obj: NDFrameT, axis: int = 0):

0 commit comments

Comments
 (0)