Dictionary

Data sampling

Data sampling means working with a subset of a dataset instead of all of it, either to move faster and cheaper or to estimate a property of the whole. It only works when the sample is representative, so how you pick the rows matters as much as how many you pick.

What is data sampling?

Data sampling means working with part of a dataset instead of all of it. You take a subset either to move faster and cheaper, or to estimate a property of the whole, such as the share of orders that are late or the average basket size.

Analysts reach for a sample during data profiling, while testing query logic on a smaller volume, or when exploring a machine learning dataset before training on everything. A filter keeps the rows that meet a condition; a sample keeps a subset meant to stand in for the whole.

Sampling methods that matter in practice

Four methods cover almost all day-to-day work.

  • Simple random. Every row has the same chance of being picked. It is the default when the data has no structure you need to protect.

  • Stratified. You split the data into groups first, then sample inside each group so the proportions are preserved. Reach for it when a subgroup is small, such as a 2 percent churn class, so it does not disappear from the sample. This is why stratified splits matter for class imbalance and for cross-validation.

  • Systematic. You take every nth row, for example every hundredth. It is quick, but only safe when the order of the rows carries no hidden pattern that lines up with your interval.

  • Cluster. You divide the data into natural groups, such as stores or regions, then sample whole groups. It is cheaper when each unit is expensive to reach, at the cost of some accuracy.

A sample is only useful if it is representative

The number of rows is the easy part. Representativeness is the hard part, and it is where most sampling goes wrong.

Convenience sampling is the usual trap: you grab the first 10,000 rows, or one region, or one month, because it is quickest. That subset bakes in whatever pattern sits at the front of the table. Those first rows may all fall in January, one region may skew older, and every conclusion then inherits that skew. This is a direct source of bias, and it drags down data quality in everything you build on the sample.

Before you trust a sample, compare a few distributions against the full dataset. Does the mix of countries, dates, or customer types roughly match? If it does not, the sample is answering a different question than the one you asked.

When sampling is safe, and when it is not

Sampling is the right tool for exploration: profiling a new source, sanity-checking a transformation, or spotting outliers before you commit compute to the whole thing.

It is the wrong tool the moment the number has to be exact. Financial totals, tax figures, and compliance or audit reporting need every row, not an estimate. A sampled revenue figure that is 3 percent off is not a smaller version of the truth, it is a wrong number.

Query engines make this concrete. BigQuery reads sampled data a block at a time with TABLESAMPLE SYSTEM (10 PERCENT), so the exact fraction of rows varies and a table under about 1 GB is read in full anyway. Spark treats the fraction in its sample method as a per-row probability, not an exact count. Both are fine for a quick look, and both return a slightly different set each run unless you fix a seed. Neither belongs in a figure you report to the tax office.

Last Updated: July 10, 2026 Back to Dictionary
Keywords
data sampling simple random sampling stratified sampling cluster sampling data profiling data quality bias machine learning statistics sampling bias