flox.Aggregation

class flox.Aggregation(name, *, numpy=None, chunk, combine, preprocess=None, finalize=None, fill_value=None, final_fill_value=<NA>, dtypes=None, final_dtype=None, reduction_type='reduce', new_dims_func=None)[source]
Attributes:
new_dims
num_new_vector_dims
__init__(name, *, numpy=None, chunk, combine, preprocess=None, finalize=None, fill_value=None, final_fill_value=<NA>, dtypes=None, final_dtype=None, reduction_type='reduce', new_dims_func=None)[source]

Blueprint for computing grouped aggregations.

See aggregations.py for examples on how to specify reductions.

Attributes:
namestr

Name of reduction.

numpystr or callable, optional

Reduction function applied to numpy inputs. This function should compute the grouped reduction and must have a specific signature. If string, these must be “native” reductions implemented by the backend engines (numpy_groupies, flox, numbagg). If None, will be set to name.

chunkNone or str or tuple of str or callable or tuple of callable

For dask inputs only. Either a single function or a list of functions to be applied blockwise on the input dask array. If None, will raise an error for dask inputs.

combineNone or str or tuple of str or callbe or tuple of callable

For dask inputs only. Functions applied when combining intermediate results from the blockwise stage (see chunk). If None, will raise an error for dask inputs.

finalizecallable

For dask inputs only. Function that combines intermediate results to compute final result.

preprocesscallable

For dask inputs only. Preprocess inputs before chunk stage.

reduction_type{“reduce”, “argreduce”}

Type of reduction.

fill_valuenumber or tuple(number), optional

Value to use when a group has no members. If single value will be converted to tuple of same length as chunk. If appropriate, provide a different fill_value per reduction in chunk as a tuple.

final_fill_valueoptional

fill_value for final result.

dtypesDType or tuple(DType), optional

dtypes for intermediate results. If single value, will be converted to a tuple of same length as chunk. If appropriate, provide a different fill_value per reduction in chunk as a tuple.

final_dtypeDType, optional

DType for output. By default, uses dtype of array being reduced.

new_dims_func: Callable

Function that receives finalize_kwargs and returns a tupleof sizes of any new dimensions added by the reduction. For e.g. quantile for q=(0.5, 0.85) adds a new dimension of size 2, so returns (2,)

Methods

__init__(name, *[, numpy, preprocess, ...])

Blueprint for computing grouped aggregations.

Attributes

new_dims

num_new_vector_dims