polars.Series.item#
- Series.item(row: int | None = None) Any [source]#
Return the series as a scalar, or return the element at the given row index.
If no row index is provided, this is equivalent to
s[0]
, with a check that the shape is (1,). With a row index, this is equivalent tos[row]
.Examples
>>> s1 = pl.Series("a", [1]) >>> s1.item() 1 >>> s2 = pl.Series("a", [9, 8, 7]) >>> s2.cumsum().item(-1) 24