From 79b6e1cb237670bcfc3237a67b1a5aa0f59c4776 Mon Sep 17 00:00:00 2001 From: montanarograziano Date: Thu, 6 Jun 2024 10:00:10 +0200 Subject: [PATCH] Add missing docstring example for Dataframe.limit --- py-polars/polars/dataframe/frame.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index e90aacf013a2..e28d8f6c4d4d 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -5066,6 +5066,29 @@ def limit(self, n: int = 5) -> Self: See Also -------- head + + Examples + -------- + Get the first 3 rows of a DataFrame. + + >>> df = pl.DataFrame( + ... { + ... "foo": [1, 2, 3, 4, 5], + ... "bar": [6, 7, 8, 9, 10], + ... "ham": ["a", "b", "c", "d", "e"], + ... } + ... ) + >>> df.limit(3) + shape: (3, 3) + ┌─────┬─────┬─────┐ + │ foo ┆ bar ┆ ham │ + │ --- ┆ --- ┆ --- │ + │ i64 ┆ i64 ┆ str │ + ╞═════╪═════╪═════╡ + │ 1 ┆ 6 ┆ a │ + │ 2 ┆ 7 ┆ b │ + │ 3 ┆ 8 ┆ c │ + └─────┴─────┴─────┘ """ return self.head(n)