Class DataFrameGroupBy (0.3.0)

DataFrameGroupBy(
    block: bigframes.core.blocks.Block,
    by_col_ids: typing.Sequence[str],
    *,
    selected_cols: typing.Optional[typing.Sequence[str]] = None,
    dropna: bool = True,
    as_index: bool = True
)

Class for grouping and aggregating relational data.

Methods

agg

agg(func=None, **kwargs) -> bigframes.dataframe.DataFrame

Aggregate using one or more operations.

Parameter
NameDescription
func function, str, list, dict or None

Function to use for aggregating the data. Accepted combinations are: - string function name - list of function names, e.g. ['sum', 'mean'] - dict of axis labels -> function names or list of such. - None, in which case kwargs are used with Named Aggregation. Here the output has one column for each element in kwargs. The name of the column is keyword, whereas the value determines the aggregation used to compute the values in the column.

aggregate

aggregate(func=None, **kwargs) -> bigframes.dataframe.DataFrame

Aggregate using one or more operations.

Parameter
NameDescription
func function, str, list, dict or None

Function to use for aggregating the data. Accepted combinations are: - string function name - list of function names, e.g. ['sum', 'mean'] - dict of axis labels -> function names or list of such. - None, in which case kwargs are used with Named Aggregation. Here the output has one column for each element in kwargs. The name of the column is keyword, whereas the value determines the aggregation used to compute the values in the column.

all

all() -> bigframes.dataframe.DataFrame

Return True if all values in the group are true, else False.

Returns
TypeDescription
Series or DataFrameDataFrame or Series of boolean values, where a value is True if all elements are True within its respective group, False otherwise.

any

any() -> bigframes.dataframe.DataFrame

Return True if any value in the group is true, else False.

Returns
TypeDescription
Series or DataFrameDataFrame or Series of boolean values, where a value is True if any element is True within its respective group, False otherwise.

count

count() -> bigframes.dataframe.DataFrame

Compute count of group, excluding missing values.

Returns
TypeDescription
Series or DataFrameCount of values within each group.

cumcount

cumcount(ascending: bool = True)

Number each item in each group from 0 to the length of that group - 1.

Parameter
NameDescription
ascending bool, default True

If False, number in reverse, from length of group - 1 to 0.

Returns
TypeDescription
SeriesSequence number of each element within each group.

cummax

cummax(
    *args, numeric_only: bool = False, **kwargs
) -> bigframes.dataframe.DataFrame

Cumulative max for each group.

Returns
TypeDescription
Series or DataFrameCumulative max for each group.

cummin

cummin(
    *args, numeric_only: bool = False, **kwargs
) -> bigframes.dataframe.DataFrame

Cumulative min for each group.

Returns
TypeDescription
Series or DataFrameCumulative min for each group.

cumprod

cumprod(*args, **kwargs) -> bigframes.dataframe.DataFrame

Cumulative product for each group.

Returns
TypeDescription
Series or DataFrameCumulative product for each group.

cumsum

cumsum(
    *args, numeric_only: bool = False, **kwargs
) -> bigframes.dataframe.DataFrame

Cumulative sum for each group.

Returns
TypeDescription
Series or DataFrameCumulative sum for each group.

diff

diff()

First discrete difference of element. Calculates the difference of each element compared with another element in the group (default is element in previous row).

Returns
TypeDescription
Series or DataFrameFirst differences.

expanding

expanding(*args, **kwargs)

Provides expanding functionality.

Returns
TypeDescription
Series or DataFrameA expanding grouper, providing expanding functionality per group.

max

max(numeric_only: bool = False, *args) -> bigframes.dataframe.DataFrame

Compute max of group values.

Parameters
NameDescription
numeric_only bool, default False

Include only float, int, boolean columns.

min_count int, default 0

The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.

Returns
TypeDescription
Series or DataFrameComputed max of values within each group.

mean

mean(numeric_only: bool = False, *args) -> bigframes.dataframe.DataFrame

Compute mean of groups, excluding missing values.

Parameter
NameDescription
numeric_only bool, default False

Include only float, int, boolean columns.

Returns
TypeDescription
pandas.Series or pandas.DataFrameMean of groups.

median

median(
    numeric_only: bool = False, *, exact: bool = False
) -> bigframes.dataframe.DataFrame

Compute median of groups, excluding missing values.

Parameters
NameDescription
numeric_only bool, default False

Include only float, int, boolean columns.

exact bool, default False

Calculate the exact median instead of an approximation. Note: exact=True not yet supported.

Returns
TypeDescription
pandas.Series or pandas.DataFrameMedian of groups.

min

min(numeric_only: bool = False, *args) -> bigframes.dataframe.DataFrame

Compute min of group values.

Parameters
NameDescription
numeric_only bool, default False

Include only float, int, boolean columns.

min_count int, default 0

The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.

Returns
TypeDescription
Series or DataFrameComputed min of values within each group.

prod

prod(numeric_only: bool = False, min_count: int = 0)

Compute prod of group values.

Parameters
NameDescription
numeric_only bool, default False

Include only float, int, boolean columns.

min_count int, default 0

The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.

Returns
TypeDescription
Series or DataFrameComputed prod of values within each group.

rolling

rolling(*args, **kwargs)

Returns a rolling grouper, providing rolling functionality per group.

Parameter
NameDescription
min_periods int, default None

Minimum number of observations in window required to have a value; otherwise, result is np.nan. For a window that is specified by an offset, min_periods will default to 1. For a window that is specified by an integer, min_periods will default to the size of the window.

Returns
TypeDescription
Series or DataFrameReturn a new grouper with our rolling appended.

shift

shift(periods: int = 1)

Shift each group by periods observations.

Parameter
NameDescription
periods int, default 1

Number of periods to shift.

Returns
TypeDescription
Series or DataFrameObject shifted within each group.

std

std(*, numeric_only: bool = False) -> bigframes.dataframe.DataFrame

Compute standard deviation of groups, excluding missing values.

For multiple groupings, the result index will be a MultiIndex.

Parameter
NameDescription
numeric_only bool, default False

Include only float, int or boolean data.

Returns
TypeDescription
Series or DataFrameStandard deviation of values within each group.

sum

sum(numeric_only: bool = False, *args) -> bigframes.dataframe.DataFrame

Compute sum of group values.

Parameters
NameDescription
numeric_only bool, default False

Include only float, int, boolean columns.

min_count int, default 0

The required number of valid values to perform the operation. If fewer than min_count non-NA values are present the result will be NA.

Returns
TypeDescription
Series or DataFrameComputed sum of values within each group.

var

var(*, numeric_only: bool = False) -> bigframes.dataframe.DataFrame

Compute variance of groups, excluding missing values.

For multiple groupings, the result index will be a MultiIndex.

Parameter
NameDescription
numeric_only bool, default False

Include only float, int or boolean data.