mesa_frames.AgentSet.select#

AgentSet.select(mask: Sequence[int] | int | Literal['all', 'active'] | None | Expr | Series | DataFrame = None, filter_func: Callable[[Self], Series] | None = None, n: int | None = None, negate: bool = False, inplace: bool = True) Self[source]#

Update the active-agent mask using selection criteria.

Parameters:
  • mask (AgentMask | None, optional) – Pre-computed mask identifying agents to activate.

  • filter_func (Callable[[Self], BoolSeries] | None, optional) – Callable evaluated on the agent set to produce an additional mask.

  • n (int | None, optional) – Randomly sample n agents from the selected mask when provided.

  • negate (bool, optional) – Invert the effective mask, by default False.

  • inplace (bool, optional) – Whether to mutate in place or return an updated copy, by default True.

Returns:

The updated AgentSet (or a modified copy when inplace=False).

Return type:

Self