Skip to content

Commit

Permalink
DOC: Expand docstrings for head / tail methods (pandas-dev#16941)
Browse files Browse the repository at this point in the history
  • Loading branch information
yosukeBaya4 authored and jowens committed Sep 20, 2017
1 parent a256e26 commit 75d46a6
Showing 1 changed file with 24 additions and 2 deletions.
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

0 comments on commit 75d46a6

Please sign in to comment.