Skip to content

Commit

Permalink
enforce keyword-only
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Jun 21, 2024
1 parent 0219f0b commit 9de041c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7589,11 +7589,11 @@ def explode(
@deprecate_renamed_parameter("columns", "on", version="1.0.0")
def pivot(
self,
*,
on: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None,
index: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None,
values: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None,
aggregate_function: PivotAgg | Expr | None = None,
*,
maintain_order: bool = True,
sort_columns: bool = False,
separator: str = "_",
Expand Down Expand Up @@ -7805,6 +7805,7 @@ def pivot(

def unpivot(
self,
*,
on: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None = None,
index: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None = None,
variable_name: str | None = None,
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/lazyframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5705,11 +5705,11 @@ def drop_nulls(

def unpivot(
self,
*,
on: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None = None,
index: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] | None = None,
variable_name: str | None = None,
value_name: str | None = None,
*,
streamable: bool = True,
) -> Self:
"""
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/operations/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_unpivot_values_predicate_pushdown() -> None:
).lazy()

assert (
lf.unpivot("id", ["asset_key_1", "asset_key_2", "asset_key_3"])
lf.unpivot(index="id", on=["asset_key_1", "asset_key_2", "asset_key_3"])
.filter(pl.col("value") == pl.lit("123"))
.collect()
).to_dict(as_series=False) == {
Expand Down
4 changes: 2 additions & 2 deletions py-polars/tests/unit/operations/test_unpivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def test_unpivot_projection_pd_7747() -> None:


# https://github.com/pola-rs/polars/issues/10075
def test_unpivot_no_value_vars() -> None:
def test_unpivot_no_on() -> None:
lf = pl.LazyFrame({"a": [1, 2, 3]})

result = lf.unpivot("a")
result = lf.unpivot(index="a")

expected = pl.LazyFrame(
schema={"a": pl.Int64, "variable": pl.String, "value": pl.Null}
Expand Down

0 comments on commit 9de041c

Please sign in to comment.