diff --git a/pandas/core/generic.py b/pandas/core/generic.py index da550dccc9c896..3d1bd2292b3594 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3563,6 +3563,40 @@ def head(self, n=5): ------- obj_head : type of caller The first n rows of the caller object. + + See Also + -------- + pandas.DataFrame.tail + + Examples + -------- + >>> df = pd.DataFrame({'animal':['bear', 'bee', 'falcon', + ... 'lion', 'monkey', 'parrot', 'shark']}) + >>> df + animal + 0 bear + 1 bee + 2 falcon + 3 lion + 4 monkey + 5 parrot + 6 shark + + Viewing the first 5 lines + >>> df.head() + animal + 0 bear + 1 bee + 2 falcon + 3 lion + 4 monkey + + Viewing the first n lines (three in this case) + >>> df.head(3) + animal + 0 bear + 1 bee + 2 falcon """ return self.iloc[:n] @@ -3580,6 +3614,41 @@ def tail(self, n=5): ------- obj_tail : type of caller The last n rows of the caller object. + + See Also + -------- + pandas.DataFrame.head + + Examples + -------- + >>> df = pd.DataFrame({'animal':['falcon', 'parrot', 'lion', + ... 'monkey', 'shark', 'bee', 'bear']}) + >>> df + animal + 0 bear + 1 bee + 2 falcon + 3 lion + 4 monkey + 5 parrot + 6 shark + + Viewing the last 5 lines + >>> df.tail() + animal + 2 falcon + 3 lion + 4 monkey + 5 parrot + 6 shark + + Viewing the last n lines (three in this case) + >>> df.tail(3) + animal + 4 monkey + 5 parrot + 6 shark + """ if n == 0: