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, duplicated_size=None, aggregated_size=None, **kwargs)¶
Bases:
StateObject
Represents a grouping of a table according to one or more columns
- as_table(**query_args)¶
Returns a table containing the grouping columns :returns: Table containing the grouping columns :rtype: 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:
- get(**query_args)¶
Return the groupby object. Can be used to turn deferred object into regular or opened object
- size(**query_args)¶
Returns sizes of the groups of the grouping
- Parameters:
query_args (query arguments)
- 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) – aggregation function to use, e.g., crandas.groupby.sum
- Returns:
CDataFrame containing the grouping columns and an aggregate of the grouped-by column
- Return type:
- 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 or name.
- Parameters:
name (str) – Handle (hex-encoded string) or name
- Returns:
The table with id id
- Return type:
- 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