mesa_frames.Grid.get_neighbors#
- Grid.get_neighbors(radius: int | Sequence[int], pos: int | Sequence[int] | DataFrame | Sequence[int | slice | Sequence[int]] | Collection[int | Sequence[int] | DataFrame] | None = None, agents: int | Collection[int] | Series | DataFrame | AbstractAgentSetRegistry | Collection[AbstractAgentSetRegistry] | None = None, include_center: bool = False) DataFrame#
Get the neighboring agents from given positions or agents according to the specified radiuses.
Either positions (pos0, pos1) or agents (agents0, agents1) must be specified, not both and they must have the same length.
- Parameters:
radius (int | float | Sequence[int] | Sequence[float] | ArrayLike) – The radius(es) of the neighborhood
pos (SpaceCoordinate | SpaceCoordinates | None, optional) – The coordinates of the cell to get the neighborhood from, by default None
agents (IdsLike | AbstractAgentSet | AbstractAgentSetRegistry | Collection[AbstractAgentSet] | Collection[AbstractAgentSetRegistry] | None, optional) – The id of the agents to get the neighborhood from, by default None
include_center (bool, optional) – If the center cells or agents should be included in the result, by default False
- Returns:
A dataframe with neighboring agents. The columns with ‘_center’ suffix represent the center agent/position.
- Return type:
DataFrame
- Raises:
ValueError – If both pos and agent are None or if both pos and agent are not None.