cudf.core.groupby.SeriesGroupBy.sample#
- SeriesGroupBy.sample(n: int | None = None, frac: float | None = None, replace: bool = False, weights: Sequence | Series | None = None, random_state: numpy.random.RandomState | int | None = None)[source]#
Return a random sample of items in each group.
- Parameters:
- n
Number of items to return for each group, if sampling without replacement must be at most the size of the smallest group. Cannot be used with frac. Default is
n=1
if frac is None.- frac
Fraction of items to return. Cannot be used with n.
- replace
Should sampling occur with or without replacement?
- weights
Sampling probability for each element. Must be the same length as the grouped frame. Not currently supported.
- random_state
Seed for random number generation.
- Returns:
- New dataframe or series with samples of appropriate size drawn
- from each group.