polars.Series.list.item#
- Series.list.item() Series[source]#
Get the single value of the sublists.
This errors if the sublist length is not exactly one.
See also
Series.list.get()Get the value by index in the sublists.
Examples
>>> s = pl.Series("a", [[1], [4], [6]]) >>> s.list.item() shape: (3,) Series: 'a' [i64] [ 1 4 6 ] >>> df = pl.Series("a", [[3, 2, 1], [1], [2]]) >>> df.list.item() Traceback (most recent call last): ... polars.exceptions.ComputeError: aggregation 'item' expected a single value, got 3 values