polars.Series.gather#
- Series.gather( ) Series[source]#
Take values by index.
- Parameters:
- indices
Index location used for selection.
- null_on_oob
Behavior if an index is out of bounds:
True -> set the result to null
False -> raise an error
Examples
>>> s = pl.Series("a", [1, 2, 3, 4]) >>> s.gather([1, 3]) shape: (2,) Series: 'a' [i64] [ 2 4 ]
Use
null_on_oob=Trueto return null for out-of-bounds indices.>>> s.gather([1, 10], null_on_oob=True) shape: (2,) Series: 'a' [i64] [ 2 null ]