- n: int | IntoExprColumn | None = None,
- fraction: float | IntoExprColumn | None = None,
- with_replacement: bool = False,
- shuffle: bool = False,
- seed: int | None = None,
Sample from this list.
Number of items to return. Cannot be used with
fraction. Defaults to 1 if
Fraction of items to return. Cannot be used with
Allow values to be sampled more than once.
Shuffle the order of sampled data points.
Seed for the random number generator. If set to None (default), a random seed is generated for each sample operation.
>>> s = pl.Series("values", [[1, 2, 3], [4, 5]]) >>> s.list.sample(n=pl.Series("n", [2, 1]), seed=1) shape: (2,) Series: 'values' [list[i64]] [ [2, 1]  ]