Skip to content

Commit 1625d5a

Browse files
jmarinturjmarinmroeschke
authored
Improving function definition (#57518)
* Improving function definition * Apply suggestions from code review Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --------- Co-authored-by: jmarin <javier.marin@satellogic.com> Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
1 parent b2b1aae commit 1625d5a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pandas/core/generic.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5468,12 +5468,13 @@ def head(self, n: int = 5) -> Self:
54685468
"""
54695469
Return the first `n` rows.
54705470
5471-
This function returns the first `n` rows for the object based
5472-
on position. It is useful for quickly testing if your object
5473-
has the right type of data in it.
5471+
This function exhibits the same behavior as ``df[:n]``, returning the
5472+
first ``n`` rows based on position. It is useful for quickly checking
5473+
if your object has the right type of data in it.
54745474
5475-
For negative values of `n`, this function returns all rows except
5476-
the last `|n|` rows, equivalent to ``df[:n]``.
5475+
When ``n`` is positive, it returns the first ``n`` rows. For ``n`` equal to 0,
5476+
it returns an empty object. When ``n`` is negative, it returns
5477+
all rows except the last ``|n|`` rows, mirroring the behavior of ``df[:n]``.
54775478
54785479
If n is larger than the number of rows, this function returns all rows.
54795480

0 commit comments

Comments
 (0)