SeriesGroupBy.resample.html)
    * [ pandas.core.groupby.SeriesGroupBy.rolling ](pandas.core.groupby.SeriesGroupBy.rolling.html)
    * pandas.core.groupby.SeriesGroupBy.sample 
    * [ pandas.core.groupby.SeriesGroupBy.sem ](pandas.core.groupby.SeriesGroupBy.sem.html)
    * [ pandas.core.groupby.SeriesGroupBy.shift ](pandas.core.groupby.SeriesGroupBy.shift.html)
    * [ pandas.core.groupby.SeriesGroupBy.size ](pandas.core.groupby.SeriesGroupBy.size.html)
    * [ pandas.core.groupby.SeriesGroupBy.skew ](pandas.core.groupby.SeriesGroupBy.skew.html)
    * [ pandas.core.groupby.SeriesGroupBy.std ](pandas.core.groupby.SeriesGroupBy.std.html)
    * [ pandas.core.groupby.SeriesGroupBy.sum ](pandas.core.groupby.SeriesGroupBy.sum.html)
    * [ pandas.core.groupby.SeriesGroupBy.var ](pandas.core.groupby.SeriesGroupBy.var.html)
    * [ pandas.core.groupby.SeriesGroupBy.tail ](pandas.core.groupby.SeriesGroupBy.tail.html)
    * [ pandas.core.groupby.SeriesGroupBy.take ](pandas.core.groupby.SeriesGroupBy.take.html)
    * [ pandas.core.groupby.SeriesGroupBy.value_counts ](pandas.core.groupby.SeriesGroupBy.value_counts.html)
    * [ pandas.core.groupby.DataFrameGroupBy.boxplot ](pandas.core.groupby.DataFrameGroupBy.boxplot.html)
    * [ pandas.core.groupby.DataFrameGroupBy.hist ](pandas.core.groupby.DataFrameGroupBy.hist.html)
    * [ pandas.core.groupby.SeriesGroupBy.hist ](pandas.core.groupby.SeriesGroupBy.hist.html)
    * [ pandas.core.groupby.DataFrameGroupBy.plot ](pandas.core.groupby.DataFrameGroupBy.plot.html)
    * [ pandas.core.groupby.SeriesGroupBy.plot ](pandas.core.groupby.SeriesGroupBy.plot.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ GroupBy ](../groupby.html)
  * pandas.core.... 

#  pandas.core.groupby.SeriesGroupBy.sample  #

SeriesGroupBy.  sample  (  _ n  =  None  _ , _ frac  =  None  _ , _ replace  =
False  _ , _ weights  =  None  _ , _ random_state  =  None  _ )  [ [source]
](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/groupby/groupby.py#L5663-L5790) #

    

Return a random sample of items from each group.

You can use  random_state  for reproducibility.

Parameters  :

    

**n** int, optional

    

Number of items to return for each group. Cannot be used with  frac  and must
be no larger than the smallest group unless  replace  is True. Default is one
if  frac  is None.

**frac** float, optional

    

Fraction of items to return. Cannot be used with  n  .

**replace** bool, default False

    

Allow or disallow sampling of the same row more than once.

**weights** list-like, optional

    

Default None results in equal probability weighting. If passed a list-like
then values must have the same length as the underlying DataFrame or Series
object and will be used as sampling probabilities after normalization within
each group. Values must be non-negative with at least one positive element
within each group.

**random_state** int, array-like, BitGenerator, np.random.RandomState,
np.random.Generator, optional

    

If int, array-like, or BitGenerator, seed for random number generator. If
np.random.RandomState or np.random.Generator, use as given.

Changed in version 1.4.0:  np.random.Generator objects now accepted

Returns  :

    

Series or DataFrame

    

A new object of same type as caller containing items randomly sampled within
each group from the caller object.

See also

` DataFrame.sample  `

    

Generate random samples from a DataFrame object.

[ ` numpy.random.choice  `
](https://numpy.org/doc/stable/reference/random/generated/numpy.random.choice.html#numpy.random.choice
"\(in NumPy v1.26\)")

    

Generate a random sample from a given 1-D numpy array.

Examples

    
    
    >>> df = pd.