diff --git a/py-polars/polars/expr/expr.py b/py-polars/polars/expr/expr.py index ead7b491a28a..eb3acf98f034 100644 --- a/py-polars/polars/expr/expr.py +++ b/py-polars/polars/expr/expr.py @@ -4752,7 +4752,10 @@ def xor(self, other: Any) -> Self: ... pl.col("x").map_elements(binary_string).alias("bin_x"), ... pl.col("y").map_elements(binary_string).alias("bin_y"), ... pl.col("x").xor(pl.col("y")).alias("xor_xy"), - ... pl.col("x").xor(pl.col("y")).apply(binary_string).alias("bin_xor_xy"), + ... pl.col("x") + ... .xor(pl.col("y")) + ... .map_elements(binary_string) + ... .alias("bin_xor_xy"), ... ) shape: (4, 6) ┌─────┬─────┬──────────┬──────────┬────────┬────────────┐ diff --git a/py-polars/tests/unit/operations/test_map.py b/py-polars/tests/unit/operations/test_map.py index 8faaf784d10e..89f9e3fe673c 100644 --- a/py-polars/tests/unit/operations/test_map.py +++ b/py-polars/tests/unit/operations/test_map.py @@ -414,3 +414,10 @@ def test_map_elements_on_empty_col_10639() -> None: "B": [], "Foo": [], } + + +def test_apply_deprecated() -> None: + with pytest.deprecated_call(): + pl.col("a").apply(lambda x: x + 1) + with pytest.deprecated_call(): + pl.Series([1, 2, 3]).apply(lambda x: x + 1)