xarray_beam.Mean

class xarray_beam.Mean(dim, skipna=True, dtype=None, fanout=None, pre_aggregate=True)

Calculate the mean over one or more distributed dataset dimensions.

This PTransform expects a PCollection of (key, chunk) pairs, and outputs a PCollection where chunks with the same key (excluding dimensions in dim) have been averaged together.

Parameters:
  • dim (str | Sequence[str]) – Dimension(s) to average over.

  • skipna (bool) – If True, skip missing values (NaN) when calculating the mean.

  • dtype (npt.DTypeLike | None) – Data type to use for sum and count accumulators.

  • fanout (int | None) – If provided, use CombinePerKey.with_hot_key_fanout to handle hot keys by injecting intermediate merging nodes.

  • pre_aggregate (bool) – If True, calculate sum and count for each chunk before combining. This is usually more efficient.

__init__(dim, skipna=True, dtype=None, fanout=None, pre_aggregate=True)
Parameters:
  • dim (str | Sequence[str])

  • skipna (bool)

  • dtype (dtype[Any] | None | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any])

  • fanout (int | None)

  • pre_aggregate (bool)

Return type:

None

Methods

__init__(dim[, skipna, dtype, fanout, ...])

annotations()

default_label()

default_type_hints()

display_data()

Returns the display data associated to a pipeline component.

expand(pcoll)

from_runner_api(proto, context)

get_resource_hints()

get_type_hints()

Gets and/or initializes type hints for this object.

get_windowing(inputs)

Returns the window function to be associated with transform's output.

infer_output_type(unused_input_type)

register_urn(urn, parameter_type[, constructor])

runner_api_requires_keyed_input()

to_runner_api(context[, has_parts])

to_runner_api_parameter(unused_context)

to_runner_api_pickled(context)

type_check_inputs(pvalueish)

type_check_inputs_or_outputs(pvalueish, ...)

type_check_outputs(pvalueish)

with_input_types(input_type_hint)

Annotates the input type of a PTransform with a type-hint.

with_output_types(type_hint)

Annotates the output type of a PTransform with a type-hint.

with_resource_hints(**kwargs)

Adds resource hints to the PTransform.

Attributes

dtype

fanout

label

pipeline

pre_aggregate

side_inputs

skipna