Table Of Contents

Search

Enter search terms or a module, class or function name.

GroupBy

GroupBy objects are returned by groupby calls: pandas.DataFrame.groupby(), pandas.Series.groupby(), etc.

Indexing, iteration

GroupBy.__iter__() Groupby iterator.
GroupBy.groups Dict {group name -> group labels}.
GroupBy.indices Dict {group name -> group indices}.
GroupBy.get_group(name[, obj]) Constructs NDFrame from group with provided name.
Grouper([key, level, freq, axis, sort]) A Grouper allows the user to specify a groupby instruction for a target object

Function application

GroupBy.apply(func, *args, **kwargs) Apply function func group-wise and combine the results together.
GroupBy.agg(func, *args, **kwargs)
GroupBy.aggregate(func, *args, **kwargs)
GroupBy.transform(func, *args, **kwargs)
GroupBy.pipe(func, *args, **kwargs) Apply a function func with arguments to this GroupBy object and return the function’s result.

Computations / Descriptive Stats

GroupBy.all([skipna]) Returns True if all values in the group are truthful, else False.
GroupBy.any([skipna]) Returns True if any value in the group is truthful, else False.
GroupBy.bfill([limit]) Backward fill the values.
GroupBy.count() Compute count of group, excluding missing values.
GroupBy.cumcount([ascending]) Number each item in each group from 0 to the length of that group - 1.
GroupBy.ffill([limit]) Forward fill the values.
GroupBy.first(**kwargs) Compute first of group values See Also ——– pandas.Series.groupby pandas.DataFrame.groupby pandas.Panel.groupby
GroupBy.head([n]) Returns first n rows of each group.
GroupBy.last(**kwargs) Compute last of group values See Also ——– pandas.Series.groupby pandas.DataFrame.groupby pandas.Panel.groupby
GroupBy.max(**kwargs) Compute max of group values See Also ——– pandas.Series.groupby pandas.DataFrame.groupby pandas.Panel.groupby
GroupBy.mean(*args, **kwargs) Compute mean of groups, excluding missing values.
GroupBy.median(**kwargs) Compute median of groups, excluding missing values.
GroupBy.min(**kwargs) Compute min of group values See Also ——– pandas.Series.groupby pandas.DataFrame.groupby pandas.Panel.groupby
GroupBy.ngroup([ascending]) Number each group from 0 to the number of groups - 1.
GroupBy.nth(n[, dropna]) Take the nth row from each group if n is an int, or a subset of rows if n is a list of ints.
GroupBy.ohlc() Compute sum of values, excluding missing values.
GroupBy.prod(**kwargs) Compute prod of group values See Also ——– pandas.Series.groupby pandas.DataFrame.groupby pandas.Panel.groupby
GroupBy.rank([method, ascending, na_option, …]) Provides the rank of values within each group.
GroupBy.pct_change([periods, fill_method, …]) Calculate pct_change of each value to previous entry in group.
GroupBy.size() Compute group sizes.
GroupBy.sem([ddof]) Compute standard error of the mean of groups, excluding missing values.
GroupBy.std([ddof]) Compute standard deviation of groups, excluding missing values.
GroupBy.sum(**kwargs) Compute sum of group values See Also ——– pandas.Series.groupby pandas.DataFrame.groupby pandas.Panel.groupby
GroupBy.var([ddof]) Compute variance of groups, excluding missing values.
GroupBy.tail([n]) Returns last n rows of each group.

The following methods are available in both SeriesGroupBy and DataFrameGroupBy objects, but may differ slightly, usually in that the DataFrameGroupBy version usually permits the specification of an axis argument, and often an argument indicating whether to restrict application to columns of a specific data type.

DataFrameGroupBy.all([skipna]) Returns True if all values in the group are truthful, else False.
DataFrameGroupBy.any([skipna]) Returns True if any value in the group is truthful, else False.
DataFrameGroupBy.bfill([limit]) Backward fill the values.
DataFrameGroupBy.corr Compute pairwise correlation of columns, excluding NA/null values.
DataFrameGroupBy.count() Compute count of group, excluding missing values
DataFrameGroupBy.cov Compute pairwise covariance of columns, excluding NA/null values.
DataFrameGroupBy.cummax([axis]) Cumulative max for each group.
DataFrameGroupBy.cummin([axis]) Cumulative min for each group.
DataFrameGroupBy.cumprod([axis]) Cumulative product for each group.
DataFrameGroupBy.cumsum([axis]) Cumulative sum for each group.
DataFrameGroupBy.describe(**kwargs) Generate descriptive statistics that summarize the central tendency, dispersion and shape of a dataset’s distribution, excluding NaN values.
DataFrameGroupBy.diff First discrete difference of element.
DataFrameGroupBy.ffill([limit]) Forward fill the values.
DataFrameGroupBy.fillna Fill NA/NaN values using the specified method.
DataFrameGroupBy.filter(func[, dropna]) Return a copy of a DataFrame excluding elements from groups that do not satisfy the boolean criterion specified by func.
DataFrameGroupBy.hist Make a histogram of the DataFrame’s.
DataFrameGroupBy.idxmax Return index of first occurrence of maximum over requested axis.
DataFrameGroupBy.idxmin Return index of first occurrence of minimum over requested axis.
DataFrameGroupBy.mad Return the mean absolute deviation of the values for the requested axis.
DataFrameGroupBy.pct_change([periods, …]) Calculate pct_change of each value to previous entry in group.
DataFrameGroupBy.plot Class implementing the .plot attribute for groupby objects.
DataFrameGroupBy.quantile Return values at the given quantile over requested axis.
DataFrameGroupBy.rank([method, ascending, …]) Provides the rank of values within each group.
DataFrameGroupBy.resample(rule, *args, **kwargs) Provide resampling when using a TimeGrouper.
DataFrameGroupBy.shift([periods, freq, …]) Shift each group by periods observations.
DataFrameGroupBy.size() Compute group sizes.
DataFrameGroupBy.skew Return unbiased skew over requested axis Normalized by N-1.
DataFrameGroupBy.take Return the elements in the given positional indices along an axis.
DataFrameGroupBy.tshift Shift the time index, using the index’s frequency if available.

The following methods are available only for SeriesGroupBy objects.

SeriesGroupBy.nlargest Return the largest n elements.
SeriesGroupBy.nsmallest Return the smallest n elements.
SeriesGroupBy.nunique([dropna]) Returns number of unique elements in the group
SeriesGroupBy.unique Return unique values of Series object.
SeriesGroupBy.value_counts([normalize, …])
SeriesGroupBy.is_monotonic_increasing Return boolean if values in the object are monotonic_increasing.
SeriesGroupBy.is_monotonic_decreasing Return boolean if values in the object are monotonic_decreasing.

The following methods are available only for DataFrameGroupBy objects.

DataFrameGroupBy.corrwith Compute pairwise correlation between rows or columns of DataFrame with rows or columns of Series or DataFrame.
DataFrameGroupBy.boxplot([subplots, column, …]) Make box plots from DataFrameGroupBy data.
Scroll To Top