add_demand
site.SiteProblem.add_demand(
demand_df,
demand_col,
location_id_col,
skip_cols=None,
)Add demand data to the site problem and validate its structure.
This method processes an input DataFrame or GeoDataFrame (or path) containing observed demand. It validates the presence of required columns and aligns the spatial or tabular data for use within the SiteProblem context.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| demand_df | (pandas.DataFrame, geopandas.GeoDataFrame or str) | The dataset containing demand information and location identifiers, or a local or web path to its location. | required |
| demand_col | str | The name of the column in demand_df representing the quantity of demand (e.g., patient counts, request volume, or other demand weighting). |
required |
| location_id_col | str | The name of the column in demand_df used as a unique identifier for demand locations. |
required |
| skip_cols | list of str | A list of column names to ignore during the data loading process. Defaults to None. | None |
Returns
| Name | Type | Description |
|---|---|---|
| None |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If the required demand_col or location_id_col are missing from the provided demand_df. |
Notes
The method updates several internal attributes: - self.demand_data: Stores the processed DataFrame. - self._demand_data_type: Stores whether the data is spatial or tabular. - self._demand_data_demand_col: Maps the demand value column. - self._demand_data_id_col: Maps the location identifier column.
See Also
_load_spatial_or_tabular_data : Internal utility for data ingestion. _validate_columns : Internal utility for schema verification.