LazyFrame.sample
sample
sample(
n: int | None = None,
frac: float | None = None,
random_state: int | None = None,
) -> LazyFrame
Return a random sample of items from the LazyFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int | None
|
Number of items to return. Cannot be used with frac. Defaults to None. |
None
|
frac
|
float | None
|
Fraction of items to return. Cannot be used with n. Should be between 0 and 1. Defaults to None. |
None
|
random_state
|
int | None
|
Seed for the random number generator. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
LazyFrame |
LazyFrame
|
A new LazyFrame with the sampled rows. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both n and frac are specified or if neither is specified. Also if frac is not between 0 and 1. |
Examples: