sample
dataframeReturns a random sample of n rows from a DataFrame
Syntax
sample(dataframe, n?) Parameters
dataframe (dataframe) The DataFrame to sample from
n (number) optional Number of rows to sample
Returns
dataframe DataFrame containing n randomly selected rows
Examples
Get a random sample of 10 rows from the DataFrame
Input:
sample(10) Output:
Random sample of 10 rows Get a larger random sample for inspection
Input:
sample(100) Output:
Random sample of 100 rows The sample() function returns a random sample of n rows from a DataFrame. This is useful for quick data exploration and testing on large datasets.
Usage
Use sample() to get a representative subset of data for testing, create training/validation splits, or quickly inspect large datasets without processing all rows.