Sample

Pydoc Pydoc




Transforms for taking samples of the elements in a collection, or samples of the values associated with each key in a collection of key-value pairs.

Examples

In the following example, we create a pipeline with a PCollection. Then, we get a random sample of elements in different ways.

Example 1: Sample elements from a PCollection

We use Sample.FixedSizeGlobally() to get a fixed-size random sample of elements from the entire PCollection.

Example 2: Sample elements for each key

We use Sample.FixedSizePerKey() to get fixed-size random samples for each unique key in a PCollection of key-values.

Pydoc Pydoc