Sample Transform
The sample transform is one of the simpler of all Altair’s data transforms;
it takes a single parameter sample
which specified a number
of rows to
randomly choose from the dataset. The resulting chart will be created using
only this random subset of the data.
For example, here we chart the full cars dataset alongside a sample of 100 rows:
import altair as alt
from vega_datasets import data
source = data.cars.url
chart = alt.Chart(source).mark_point().encode(
x='Horsepower:Q',
y='Miles_per_Gallon:Q',
color='Origin:N'
).properties(
width=200,
height=200
)
chart | chart.transform_sample(100)
Transform Options
The transform_sample()
method is built on the SampleTransform
class, which has the following options:
Property |
Type |
Description |
---|---|---|
sample |
|
The maximum number of data objects to include in the sample. Default value: |