Skip to content

crandas.groupby

Crandas groupby functionality. See Group by

CDataFrameGroupBy = DataFrameGroupBy module-attribute

Deprecated

Use of this alias is deprecated

Alias for DataFrameGroupBy

any = Aggregator('any') module-attribute

Aggregator that takes an arbitrary value from the set of values (useful e.g. if all values are known to be the same; this aggregator is faster than min/max and can be applied to any column type). When applied with the same grouping and multiple columns, the same rows are selected from the respective columns.

max = Aggregator('max') module-attribute

Aggregator that computes the maximum of the given values

mean = Aggregator('mean') module-attribute

Aggregator that computes the mean of the given values

min = Aggregator('min') module-attribute

Aggregator that computes the minimum of the given values

sum = Aggregator('sum') module-attribute

Aggregator that computes the sum of the given values

Aggregator(aggregator)

Aggregation functions for use as arguments to agg()

CSeriesGroupBy(groupby, col)

Represents a grouping of a table column according to the values of one or more other columns

agg(fn, *, threshold=None, **query_args)

Aggregate column according to grouping

PARAMETER DESCRIPTION
fn

aggregation function to use, e.g., crandas.groupby.sum or the relevant string e.g. "sum"

TYPE: Aggregator | string

threshold

If given, only succeed as long as all groupings have at least this many elements.

TYPE: Optional[MaybePlaceholder[NonNegativeInt]] DEFAULT: None

query_args

TYPE: (optional, dict) DEFAULT: {}

RETURNS DESCRIPTION
DataFrame

Dataframe containing the grouping columns and an aggregate of the grouped-by column

any(*, threshold=None, **query_args)

Equivalent to agg(cd.groupby.any)

max(*, threshold=None, **query_args)

Equivalent to agg(cd.groupby.max)

mean(*, threshold=None)

Equivalent to agg(cd.groupby.mean)

min(*, threshold=None, **query_args)

Equivalent to agg(cd.groupby.min)

sum(*, threshold=None, **query_args)

Equivalent to agg(cd.groupby.sum)

DataFrameGroupBy()

Bases: StateObject

Represents a grouping of a table according to one or more columns

__getitem__(key)

__getitem__(key: str) -> CSeriesGroupBy

See .col()

as_table(**query_args)

Returns a table containing the grouping columns

PARAMETER DESCRIPTION
query_args

TYPE: (optional, dict) DEFAULT: {}

RETURNS DESCRIPTION
DataFrame

Table containing the grouping columns

col(col)

Returns a reference to another grouping grouped according to the grouping

PARAMETER DESCRIPTION
col

Name of the column

TYPE: str

RETURNS DESCRIPTION
CSeriesGroupBy

Grouping of the column for use e.g. in aggregation

size(**query_args)

Returns sizes of the groups of the grouping

PARAMETER DESCRIPTION
query_args

TYPE: (optional, dict) DEFAULT: {}

RETURNS DESCRIPTION
DataFrame

Dataframe with column of grouping values and column of counts

get(id_, *, table, columns, **query_args)

Access groupby object by name. Access a previously computed groupby object by its handle.

PARAMETER DESCRIPTION
id_

Handle (hex-encoded string)

TYPE: str

query_args

TYPE: (optional, dict) DEFAULT: {}

RETURNS DESCRIPTION
DataFrameGroupBy

The table with id id

RAISES DESCRIPTION
ValueError

Schema not specified for importing from a transaction