From f31746d4726174cee9a7362f6a76c93b40c6e0ed Mon Sep 17 00:00:00 2001 From: Benjamin Rio Date: Tue, 22 Feb 2022 14:52:46 +0100 Subject: [PATCH] Update generic.py Added documentation on head and tail methods. Parameter n can be larger than the object size. --- pandas/core/generic.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 9f9dffaaa399f..a18494bb38853 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -5161,11 +5161,13 @@ def head(self: NDFrameT, n: int = 5) -> NDFrameT: For negative values of `n`, this function returns all rows except the last `n` rows, equivalent to ``df[:-n]``. + + `n` can be larger than the object size (this conforms with python/numpy slice semantics). Parameters ---------- n : int, default 5 - Number of rows to select. + Number of rows to select. Returns ------- @@ -5235,10 +5237,12 @@ def tail(self: NDFrameT, n: int = 5) -> NDFrameT: For negative values of `n`, this function returns all rows except the first `n` rows, equivalent to ``df[n:]``. + `n` can be larger than the object size (this conforms with python/numpy slice semantics). + Parameters ---------- n : int, default 5 - Number of rows to select. + Number of rows to select. Returns -------