diff --git a/py-polars/polars/expr/expr.py b/py-polars/polars/expr/expr.py index 94dc014bede4..06b814fd79d4 100644 --- a/py-polars/polars/expr/expr.py +++ b/py-polars/polars/expr/expr.py @@ -4866,6 +4866,12 @@ def map_elements( `pl.col("col_name").sqrt()`. - For mapping inner elements of lists, consider: `pl.col("col_name").list.eval(pl.element().sqrt())`. + - For mapping elements of struct fields, consider: + `pl.col("col_name").struct.field("field_name").sqrt()`. + + If you want to replace the original column or field, + consider :meth:`.with_columns ` + and :meth:`.with_fields `. The UDF is applied to each element of a column. Note that, in a GroupBy context, the column will have been pre-aggregated and so each element diff --git a/py-polars/polars/series/series.py b/py-polars/polars/series/series.py index d5d777549643..129e30fa2921 100644 --- a/py-polars/polars/series/series.py +++ b/py-polars/polars/series/series.py @@ -5451,6 +5451,8 @@ def map_elements( - For mapping elements of a series, consider: `s.sqrt()`. - For mapping inner elements of lists, consider: `s.list.eval(pl.element().sqrt())`. + - For mapping elements of struct fields, consider: + `s.struct.field("field_name").sqrt()`. If the function returns a different datatype, the return_dtype arg should be set, otherwise the method will fail.