This is the documentation of CityLearn 3.8.2. Use the version selector or Other versions in the left sidebar to switch to an earlier release or to the development documentation (dev).

citylearn.exporter module

class citylearn.exporter.EpisodeExporter(env: CityLearnEnv)[source]

Bases: object

Internal helper that owns rendering/export behaviour for CityLearnEnv.

DEFAULT_RENDER_START_DATE = datetime.date(2024, 1, 1)
ensure_output_dir(*, ensure_exists: bool = True)[source]

Prepare the render output directory and optionally create it on disk.

export_business_as_usual_timeseries(source_env: CityLearnEnv = None)[source]

Export a compact time-series audit for the business-as-usual baseline.

export_episode_render_data(final_index: int)[source]

Export full episode render rows in one pass for render_mode='end'.

export_final_kpis(model: Agent = None, filepath: str = 'exported_kpis.csv', include_business_as_usual: bool = True, export_business_as_usual_timeseries: bool = True, kpi_round_decimals: int | None = None, include_battery_health_audit: bool = False, *, evaluated_kpis: pd.DataFrame | None = None) → Mapping[str, Any][source]

Export episode KPIs to csv or parquet, with a manifest; return the manifest.

evaluated_kpis is this env’s evaluate_v2(include_business_as_usual=include_business_as_usual, include_battery_health_audit=include_battery_health_audit) table when the caller already has it, so it is not evaluated twice. The manifest records these three export settings under kpi_export.

export_origin() → datetime[source]

Time of global row 0 in exported timestamps when they do not come from a calendar file.

Its time of day is that of the dataset’s calendar columns and its date the start_date, or the date that the month and day_type columns give (#460); see citylearn.internal.temporal.calendar_export_origin(). Aware in the schema timezone, if any. An environment without calendar columns starts at midnight of render_start_date.

flush_render_buffer()[source]

Write any buffered render rows to disk.

get_iso_timestamp() → str[source]

Return current episode timestamp string in ISO format.

override_render_time_step(index: int)[source]

Temporarily set time_step to index for the environment and descendants.

static parse_render_start_date(start_date: str | date | datetime) → date[source]

Return a valid start date for rendering timestamps.

render()[source]

Render one time step to configured time-series outputs.

reset_time_tracking()[source]

Reset render timestamp tracking to episode start.

static restore_render_time_step(snapshot)[source]
save_to_csv(filename: str, data: Mapping[str, Any])[source]

Save one render row to configured output format.

write_render_rows(filename: str, rows: List[Mapping[str, Any]])[source]

Write one or more render rows to disk with minimal rewrites.