group

class AnnotatedGroup(trajectories, *, target, observations, categories, background_category)

Bases: Group, AnnotatedSampleableMixin

Annotated group.

Parameters:
  • trajectories (Iterable[Trajectory] | Mapping[str | int, Trajectory]) – Individual trajectories to be included in the group.

  • target (Literal['individual', 'dyad']) – The target of the group.

  • observations (DataFrame) – Observations for the group.

  • categories (tuple[str, ...]) – Categories of the observations.

  • background_category (str) – Background category of the observations.

class Group(trajectories, *, target)

Bases: NestedSampleableMixin, SampleableMixin

A group is a collection of individuals (Individual) or dyads (Dyad), depending on the target.

Parameters:
classmethod REQUIRED_COLUMNS(target=None)

Returns the required columns for annotations with the given target.

Parameters:

target (default: None) – The target type for the annotations.

Return type:

tuple[Literal['actor'], Literal['category'], Literal['start'], Literal['stop']] | tuple[Literal['actor'], Literal['recipient'], Literal['category'], Literal['start'], Literal['stop']]

Returns:

The required columns for annotations.

annotate(observations, *, categories, background_category)

Annotates the group with the given observations.

Parameters:
  • observations (DataFrame) – The observations.

  • categories (tuple[str, ...]) – Categories of the observations.

  • background_category (str) – The background category of the observations.

Return type:

AnnotatedGroup

Returns:

The annotated group.

classmethod from_group(group, *, individuals, subset_actors_only)

Create a new group as a subset of the original group.

Parameters:
  • group (Self) – The original group to create a subset from.

  • individuals (Sequence[str | int]) – The individuals to include in the new group.

  • subset_actors_only (bool) – Only applicable when target="dyad". Whether to drop dyads with non-included individuals as actors or recipients, or only when they are actors.

Return type:

Self

Returns:

A new group containing only the specified individuals.

property individuals: tuple[str | int, ...]

Returns the identifiers of individuals in the group.

property potential_identifiers: tuple[str | int, ...] | tuple[tuple[str | int, str | int], ...]

Returns the identifiers of individuals or all potential identifiers of dyads in the group (all combinations of individuals).