From 43a62af88a0fdc62d1058bf48fc17e5ca0e79241 Mon Sep 17 00:00:00 2001 From: avimallu <66530011+avimallu@users.noreply.github.com> Date: Tue, 30 Apr 2024 20:36:20 -0500 Subject: [PATCH 1/2] Update reference to `apply` Removed the reference to `apply` as indicated in https://github.com/pola-rs/polars/issues/15945 and replaced with `map_rows` or `map_elements` as appropriate. --- py-polars/polars/dataframe/frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index 543b429a6c25..3b39734254be 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -6199,10 +6199,10 @@ def map_rows( Notes ----- - * The frame-level `apply` cannot track column names (as the UDF is a black-box + * The frame-level `map_rows` cannot track column names (as the UDF is a black-box that may arbitrarily drop, rearrange, transform, or add new columns); if you want to apply a UDF such that column names are preserved, you should use the - expression-level `apply` syntax instead. + expression-level `map_elements` syntax instead. * If your function is expensive and you don't want it to be called more than once for a given input, consider applying an `@lru_cache` decorator to it. From 656c4227ec527968ed0771a45b6e36ccadb36a74 Mon Sep 17 00:00:00 2001 From: avimallu <66530011+avimallu@users.noreply.github.com> Date: Wed, 1 May 2024 09:53:42 -0500 Subject: [PATCH 2/2] Reduce line length to satisfy `ruff` --- py-polars/polars/dataframe/frame.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index 3b39734254be..7a47082b4d29 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -6199,10 +6199,10 @@ def map_rows( Notes ----- - * The frame-level `map_rows` cannot track column names (as the UDF is a black-box - that may arbitrarily drop, rearrange, transform, or add new columns); if you - want to apply a UDF such that column names are preserved, you should use the - expression-level `map_elements` syntax instead. + * The frame-level `map_rows` cannot track column names (as the UDF is a + black-box that may arbitrarily drop, rearrange, transform, or add new + columns); if you want to apply a UDF such that column names are preserved, + you should use the expression-level `map_elements` syntax instead. * If your function is expensive and you don't want it to be called more than once for a given input, consider applying an `@lru_cache` decorator to it.