polars.Series.__getitem__#
- Series.__getitem__(key: SingleIndexSelector | MultiIndexSelector) Any | Series [source]#
Get part of the Series as a new Series or scalar.
- Parameters:
- key
Row(s) to select.
- Returns:
- Series or scalar, depending on
key
.
- Series or scalar, depending on
Examples
>>> s = pl.Series("a", [1, 4, 2]) >>> s[0] 1 >>> s[0:2] shape: (2,) Series: 'a' [i64] [ 1 4 ]