Skip to content
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

DOC: Expand docstrings for head / tail methods #16941

Merged
merged 3 commits into from
Aug 21, 2017
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
26 changes: 24 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2978,14 +2978,36 @@ def filter(self, items=None, like=None, regex=None, axis=None):

def head(self, n=5):
"""
Returns first n rows
Return the first n rows.

Parameters
----------
n : int, default 5
Number of rows to select.

Returns
-------
obj_head : type of caller
The first n rows of the caller object.
"""

return self.iloc[:n]

def tail(self, n=5):
"""
Returns last n rows
Return the last n rows.

Parameters
----------
n : int, default 5
Number of rows to select.

Returns
-------
obj_tail : type of caller
The last n rows of the caller object.
"""

if n == 0:
return self.iloc[0:0]
return self.iloc[-n:]
Expand Down