swarmsim.world.spawners.ExcelSpawner#
Module for importing/exporting agent properties from/to spreadsheets.
Examples
Saving agent properties to a spreadsheet:
from swarmsim.world.spawners.ExcelSpawner import world_to_df
from swarmsim.world import config_from_yaml
from swarmsim.util.pdutils import save_df
# load the world config with your spawners and agents
world = config_from_yaml('world.yaml').create_world()
# setup world, create agents and spawners and do a spawn cycle
world.setup(step_spawners=True)
# save agent properties to a spreadsheet
df = world_to_df(world, as_repr=repr)
save_df(df, 'test.xlsx', sheet_name='sheet1')
Loading agent properties from a spreadsheet:
type: "RectangularWorld"
- type: ExcelSpawner
file_name: 'test.xlsx'
sheet: sheet1
agent:
type: MazeAgent
agent_radius: 0.15
Class#
- class swarmsim.world.spawners.ExcelSpawner.ExcelSpawner(world=None, n=None, file_name: str | PathLike = '', sheet=0, load_args=None, **kwargs)[source]#
Methods
do_spawn
extract_states_from_xlsx
generate_config
get_sheet
load_csv
load_from_file
load_xlsx
make_agent
set_agent_config
set_seed
set_states_from_xlsx
set_to_world
step
Functions#
- swarmsim.world.spawners.ExcelSpawner.world_to_df(world, properties=None, as_repr: str | bool | Callable = 'str')[source]#
Get agent properties from a world’s population as a pandas DataFrame.
- Parameters:
world (World) – The world to get the agent properties from.
properties (_type_, default=[name', 'position', 'angle']) – The properties of agents to scrape. These should be accessible as
agent.property_name
as_repr (str | bool | Callable, default='str') – How to represent the agent properties. If ‘str’, the properties will be converted to strings. If ‘repr’,
repr()
will be called with the properties.
- Return type:
pandas.DataFrame
Functions
|
|
|
|
|
Get agent properties from a world's population as a pandas DataFrame. |
Classes
|