turicreate.SFrame.sample¶
-
SFrame.
sample
(fraction, seed=None, exact=False)¶ Sample a fraction of the current SFrame’s rows.
Parameters: - fraction : float
Fraction of the rows to fetch. Must be between 0 and 1. if exact is False (default), the number of rows returned is approximately the fraction times the number of rows.
- seed : int, optional
Seed for the random number generator used to sample.
- exact: bool, optional
Defaults to False. If exact=True, an exact fraction is returned, but at a performance penalty.
Returns: - out : SFrame
A new SFrame containing sampled rows of the current SFrame.
Examples
Suppose we have an SFrame with 6,145 rows.
>>> import random >>> sf = SFrame({'id': range(0, 6145)})
Retrieve about 30% of the SFrame rows with repeatable results by setting the random seed.
>>> len(sf.sample(.3, seed=5)) 1783