the Polars user guide on Lists and Arrays explains how to manipulate Lists with common expression syntax using .list.eval(), i.e. how to operate on list elements. More specifically, the user guide states: The function eval gives us access to the list elements and pl.element refers to each individual element, but we can also use pl.all() to refer to all of the elements of the list. I do not understand the difference between using pl.element() vs pl.all(), i.e. when this distinction between individual and all elements mentioned in the quote becomes important. In the example below, both yield exactly the same result for various expressions. What am I missing? Thank you so much for your help! import polars as pl df = pl.DataFrame( { "a": [[1], [3,2], [6,4,5]] } ) print(df) shape: (3, 1) ┌───────────┐ │ a │ │ --- │ │ list[i64] │ ╞═══════════╡ │ [1] │ │ [3, 2] │ │ [6, 4, 5] │ └───────────┘ ## using pl.element() result_element = df.with_columns( pl.col("a").list.eval(pl.element()**2).alias("square"), pl.col("a").list.eval(pl.element().rank()).alias("rank"), pl.col("a").list.eval(pl.element().count()).alias("count") ) ## using pl.all() result_all = df.with_columns( pl.col("a").list.eval(pl.all()**2).alias("square"), pl.col("a").list.eval(pl.all().rank()).alias("rank"), pl.col("a").list.eval(pl.all().count()).alias("count") ) print(result_element.equals(result_all)) True Continue reading...