From e730630ba2bdf40669fc9bf1aee357134c2d3b36 Mon Sep 17 00:00:00 2001 From: Ho <921345@emea.kuoni.int> Date: Fri, 15 Dec 2017 13:33:04 +0000 Subject: [PATCH] DOC: Adding example and See also to head and tail method (#16416) --- pandas/core/generic.py | 76 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index da550dccc9c89..4eb7865523cc3 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3563,6 +3563,44 @@ 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':['alligator', 'bee', 'falcon', 'lion', + ... 'monkey', 'parrot', 'shark', 'whale', 'zebra']}) + >>> df + animal + 0 alligator + 1 bee + 2 falcon + 3 lion + 4 monkey + 5 parrot + 6 shark + 7 whale + 8 zebra + + Viewing the first 5 lines + + >>> df.head() + animal + 0 alligator + 1 bee + 2 falcon + 3 lion + 4 monkey + + Viewing the first n lines (three in this case) + + >>> df.head(3) + animal + 0 alligator + 1 bee + 2 falcon """ return self.iloc[:n] @@ -3580,6 +3618,44 @@ 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':['alligator', 'bee', 'falcon', 'lion', + ... 'monkey', 'parrot', 'shark', 'whale', 'zebra']}) + >>> df + animal + 0 alligator + 1 bee + 2 falcon + 3 lion + 4 monkey + 5 parrot + 6 shark + 7 whale + 8 zebra + + Viewing the last 5 lines + + >>> df.tail() + animal + 4 monkey + 5 parrot + 6 shark + 7 whale + 8 zebra + + Viewing the last n lines (three in this case) + + >>> df.tail(3) + animal + 6 shark + 7 whale + 8 zebra """ if n == 0: