snowflake.snowpark.DataFrame.sample¶
- DataFrame.sample(frac: Optional[float] = None, n: Optional[int] = None) DataFrame[source]¶
Returns a random sample of rows using Snowflake’s SQL SAMPLE clause.
Specify either
fracorn. Fractional sampling includes each row with the given probability, so the number of returned rows can vary. Fixed-size sampling returns the requested number of rows, or all rows if the input contains fewer rows. Neither form guarantees row order. Repeated executions can return different samples; this method has no seed parameter. For seeded sampling of a table, seeTable.sample().See SAMPLE for SQL sampling semantics.
- Parameters:
frac – The probability of selecting each row, from 0.0 to 1.0 inclusive. For example, 0.1 requests approximately 10 percent of the rows, not exactly 10 percent.
n – the number of rows to sample in the range of 0 to 1,000,000 (inclusive).
- Returns:
a
DataFramecontaining the sample of rows.
Examples: