Skip to content

Improving function definition #57518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5468,12 +5468,13 @@ def head(self, n: int = 5) -> Self:
"""
Return the first `n` rows.

This function returns the first `n` rows for the object based
on position. It is useful for quickly testing if your object
has the right type of data in it.
This function exhibits the same behavior as ``df[:n]``, returning the
first ``n`` rows based on position. It is useful for quickly checking
if your object has the right type of data in it.

For negative values of `n`, this function returns all rows except
the last `|n|` rows, equivalent to ``df[:n]``.
When ``n`` is positive, it returns the first ``n`` rows. For ``n`` equal to 0,
it returns an empty object. When ``n`` is negative, it returns
all rows except the last ``|n|`` rows, mirroring the behavior of ``df[:n]``.

If n is larger than the number of rows, this function returns all rows.

Expand Down