aggregators

This module gathers aggregators

class Aggregator(in_scales=None, out_scale=None, in_stype=None, out_stype=None)

Bases: BaseAggregator[I_S, O_S], ABC

This abstract class represents a typical aggregator.

Parameters
  • in_scales (Union[I_S, Mapping[Any, I_S], None]) – input scales (inferred from input if not provided)

  • out_scale (Union[O_S, None]) – output scales (inferred from output if not provided)

  • in_stype (Union[Type[I_S], None]) – input stype (inferred from input if not provided)

  • out_stype (Union[Type[O_S], None]) – output stype (inferred from output if not provided)

Raises

TypeError

  • if in_scales is not consistent with in_stype (and both are set)

  • if out_scale is not an instance of out_stype (and both are set)

Note

For all subclasses, out_scale is only used as the scale for returned aggregation results.

Warning

For all subclasses, in_scales is only declarative, and not use for checking/transforming data.

__call__(data: Series, *args, **kwargs) Any
__call__(data: Values[I_S], *args, **kwargs) Any
__call__(data: DataFrame, *args, **kwargs) Series
__call__(data: IValueMatrix[I_S], *args, **kwargs) CommensurableValues[O_S]
__call__(data: PartialValueMatrix[I_S], *args, **kwargs) AdjacencyValueMatrix[O_S]

Apply aggregation method to input data.

Parameters

data

Returns

aggregation result

Note

aggregation is applied for each row in case of tabular data

within_in_scales(data)

Check potential input is inside input scales.

Parameters

data (Union[Series, Values[I_S], DataFrame, IValueMatrix[I_S], PartialValueMatrix[I_S]]) –

Returns

True if data is within in_scales

Return type

bool

class BaseAggregator(in_scales=None, out_scale=None, in_stype=None, out_stype=None)

Bases: Generic[I_S, O_S], ABC

This abstract class represents a basic aggregator.

param in_scales

input scales (inferred from input if not provided)

param out_scale

output scales (inferred from output if not provided)

param in_stype

input stype (inferred from input if not provided)

param out_stype

output stype (inferred from output if not provided)

raise TypeError
  • if in_scales is not consistent with in_stype (and both are set)

  • if out_scale is not an instance of out_stype (and both are set)

Note

out_scale is only used as the scale for returned aggregation results.

Warning

in_scales is only declarative, and not used for checking/transforming data.

New in version 1.1.0: a more generic aggregator as common parent class

Parameters
  • in_scales (Union[I_S, Mapping[Any, I_S], None]) –

  • out_scale (Union[O_S, None]) –

  • in_stype (Union[Type[I_S], None]) –

  • out_stype (Union[Type[O_S], None]) –

abstract __call__(data, *args, **kwargs)

Apply aggregation method to input data.

Parameters

data (IValueMatrix[I_S]) –

Returns

aggregation result

Return type

CommensurableValues[O_S]

Note

aggregation is applied for each row in case of tabular data

within_in_scales(data)

Check potential input is inside input scales.

Parameters

data (IValueMatrix[I_S]) –

Returns

True if data is within in_scales

Return type

bool