- n: int | None = None,
- fraction: float | None = None,
- with_replacement: bool = False,
- shuffle: bool = False,
- seed: int | None = None,
Sample from this Series.
Number of items to return. Cannot be used with fraction. Defaults to 1 if fraction is None.
Fraction of items to return. Cannot be used with n.
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("a", [1, 2, 3, 4, 5]) >>> s.sample(2, seed=0) shape: (2,) Series: 'a' [i64] [ 1 5 ]