Skip to content

Commit

Permalink
last never ambiguous
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Harbeck committed Jul 31, 2024
1 parent 0e775bb commit d079a02
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions py-polars/polars/dataframe/group_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def last(self) -> DataFrame:
>>> df = pl.DataFrame(
... {
... "a": [1, 2, 2, 3, 4, 5],
... "b": [0.5, 0.5, 4, 10, 13, 14],
... "b": [0.5, 0.5, 4, 10, 14, 13],
... "c": [True, True, True, False, False, True],
... "d": ["Apple", "Orange", "Apple", "Apple", "Banana", "Banana"],
... }
Expand All @@ -547,7 +547,7 @@ def last(self) -> DataFrame:
╞════════╪═════╪══════╪═══════╡
│ Apple ┆ 3 ┆ 10.0 ┆ false │
│ Orange ┆ 2 ┆ 0.5 ┆ true │
│ Banana ┆ 5 ┆ 14.0 ┆ true │
│ Banana ┆ 5 ┆ 13.0 ┆ true │
└────────┴─────┴──────┴───────┘
"""
return self.agg(F.all().last())
Expand Down
4 changes: 2 additions & 2 deletions py-polars/polars/expr/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def last(self) -> Expr:
Examples
--------
>>> df = pl.DataFrame(
... {"a": [[1, 2, 3], [4, 5, 6], [7, 8, 9]]},
... {"a": [[1, 2, 3], [4, 5, 6], [7, 9, 8]]},
... schema={"a": pl.Array(pl.Int32, 3)},
... )
>>> df.with_columns(last=pl.col("a").arr.last())
Expand All @@ -524,7 +524,7 @@ def last(self) -> Expr:
╞═══════════════╪══════╡
│ [1, 2, 3] ┆ 3 │
│ [4, 5, 6] ┆ 6 │
│ [7, 8, 9] ┆ 9
│ [7, 9, 8] ┆ 8
└───────────────┴──────┘
"""
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3355,7 +3355,7 @@ def last(self) -> Expr:
Examples
--------
>>> df = pl.DataFrame({"a": [1, 1, 2]})
>>> df = pl.DataFrame({"a": [1, 3, 2]})
>>> df.select(pl.col("a").last())
shape: (1, 1)
┌─────┐
Expand Down
4 changes: 2 additions & 2 deletions py-polars/polars/lazyframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4932,7 +4932,7 @@ def last(self) -> LazyFrame:
--------
>>> lf = pl.LazyFrame(
... {
... "a": [1, 3, 5],
... "a": [1, 5, 3],
... "b": [2, 4, 6],
... }
... )
Expand All @@ -4943,7 +4943,7 @@ def last(self) -> LazyFrame:
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
5 ┆ 6 │
3 ┆ 6 │
└─────┴─────┘
"""
return self.tail(1)
Expand Down
4 changes: 2 additions & 2 deletions py-polars/polars/lazyframe/group_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def last(self) -> LazyFrame:
>>> ldf = pl.DataFrame(
... {
... "a": [1, 2, 2, 3, 4, 5],
... "b": [0.5, 0.5, 4, 10, 13, 14],
... "b": [0.5, 0.5, 4, 10, 14, 13],
... "c": [True, True, True, False, False, True],
... "d": ["Apple", "Orange", "Apple", "Apple", "Banana", "Banana"],
... }
Expand All @@ -453,7 +453,7 @@ def last(self) -> LazyFrame:
╞════════╪═════╪══════╪═══════╡
│ Apple ┆ 3 ┆ 10.0 ┆ false │
│ Orange ┆ 2 ┆ 0.5 ┆ true │
│ Banana ┆ 5 ┆ 14.0 ┆ true │
│ Banana ┆ 5 ┆ 13.0 ┆ true │
└────────┴─────┴──────┴───────┘
"""
return self.agg(F.all().last())
Expand Down
4 changes: 2 additions & 2 deletions py-polars/polars/series/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,15 @@ def last(self) -> Series:
Examples
--------
>>> s = pl.Series(
... "a", [[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=pl.Array(pl.Int32, 3)
... "a", [[1, 2, 3], [4, 5, 6], [7, 9, 8]], dtype=pl.Array(pl.Int32, 3)
... )
>>> s.arr.last()
shape: (3,)
Series: 'a' [i32]
[
3
6
9
8
]
"""
Expand Down

0 comments on commit d079a02

Please sign in to comment.