Skip to content

export_data_collection

export_data_collection

ExportDataCollection: Format-agnostic container for scenario export data.

This module provides a structured way to collect and organize all export data from scenarios without applying any format-specific transformations. It serves as an intermediate representation that can be used to export to any file format.

Classes

ExportDataCollection

Bases: BaseModel

Format-agnostic container for scenario export data.

Stores data as pandas DataFrames/dicts without format-specific transformations. See examples/export_data_collection.ipynb for usage examples.

Functions
to_dict
to_dict()

Serialize to nested dictionary structure.

Source code in src/pyetm/models/export_data_collection.py
def to_dict(self) -> dict[str, Any]:
    """Serialize to nested dictionary structure."""
    result = {"main_info": self._safe_to_dict(self.main_info)}

    # Convert simple DataFrames
    for field in ["inputs", "sortables", "gquery_results", "users", "inputs_detailed"]:
        value = getattr(self, field, None)
        if value is not None:
            result[field] = self._safe_to_dict(value)

    # Convert nested dicts
    for field in ["custom_curves", "hourly_output_curves", "annual_exports"]:
        value = getattr(self, field, None)
        if value is not None:
            result[field] = self._convert_nested_dict(value)

    result["config"] = self.config.model_dump()
    return result
__repr__
__repr__()

Human-readable summary of the export data collection.

Source code in src/pyetm/models/export_data_collection.py
def __repr__(self) -> str:
    """Human-readable summary of the export data collection."""
    lines = [
        "ExportDataCollection(",
        f"  main_info: {self._format_dataframe_shape(self.main_info)} fields)",
    ]

    # Add optional DataFrames
    for field in ["inputs", "sortables", "gquery_results", "users", "inputs_detailed"]:
        lines.extend(self._format_optional_field(field))

    # Add nested dicts
    for field in ["custom_curves", "hourly_output_curves", "annual_exports"]:
        lines.extend(self._format_nested_field(field))

    lines.append(")")
    return "\n".join(lines)