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 -------