crandas.groupby

Crandas groupby functionality. See Group by: split-apply-combine

class crandas.groupby.Aggregator(aggregator)

Bases: object

Aggregation functions for use as arguments to CSeriesGroupBy.agg()

class crandas.groupby.CDataFrameGroupBy(table, columns, **kwargs)

Bases: StateObject

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

__getitem__(key)

See col()

as_table(**query_args)

Returns a table containing the grouping columns

Parameters:

query_args – See queryargs

Returns:

Table containing the grouping columns

Return type:

CDataFrame

col(col)

Returns a reference to another grouping grouped according to the grouping

Parameters:

col (str) – Name of the column

Returns:

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

Return type:

CSeriesGroupBy

size(**query_args)

Returns sizes of the groups of the grouping

Parameters:

query_args – See queryargs

Returns:

CDataFrame with column of grouping values and column of counts

Return type:

CDataFrame/DataFrame

class crandas.groupby.CSeriesGroupBy(groupby, col)

Bases: object

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

agg(fn, **query_args)

Aggregate column according to grouping

Parameters:
  • fn (Aggregator | string) – aggregation function to use, e.g., crandas.groupby.sum or the relevant string e.g. “sum”

  • query_args – See queryargs

Returns:

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

Return type:

CDataFrame

crandas.groupby.any = <crandas.groupby.Aggregator object>

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)

crandas.groupby.get(id_, *, table, columns, **query_args)

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

Parameters:
  • id (str) – Handle (hex-encoded string)

  • query_args – See queryargs

Returns:

The table with id id

Return type:

CDataFrameGroupBy

Raises:

ValueError – Schema not specified for importing from a transaction

crandas.groupby.max = <crandas.groupby.Aggregator object>

Aggregator that computes the maximum of the given values

crandas.groupby.min = <crandas.groupby.Aggregator object>

Aggregator that computes the minimum of the given values

crandas.groupby.sum = <crandas.groupby.Aggregator object>

Aggregator that computes the sum of the given values