Shape · Rows

Random Sample

Picks a random set of rows, either a fixed number or a share such as 10%. You can sample with replacement, or stratify by a column so each group keeps its share. Set a seed to get the same rows every time.

Also known as: Downsample, stratified sample

How it works

Mode is Count, with Number of rows (10 by default), or Fraction, with a share between 0 and 1 (0.1 by default). Seed (optional) makes the pick repeatable; blank draws different rows on every run. With replacement lets a row be picked more than once. Stratify by (optional) samples each value of a column separately so every group keeps its share. On the desktop a count larger than the table fails the run; when plain sampling is pushed down to the drone it returns every row instead. Plain sampling runs on the drone; With replacement and Stratify by run on the desktop instead.

Inputs and outputs

Inputs

  • data — Table

Outputs

  • data — Table

Settings

The Attributes panel of Random Sample, as in the app: the controls work, but nothing runs — there is no data behind it.

The same settings, as the Assistant writes them
{
  mode: "n"|"fraction"
  n?: number
  fraction?: number
  seed?: number
  withReplacement: boolean
  stratifyBy?: string
}

Example

A 10% sample of support tickets that keeps the mix of priorities: Mode Fraction 0.1, Seed 7, Stratify by priority.