Utilities API
utils
Static information and general utility functions for pypsa_validation_processing.
remap_unit_index(series: pd.Series | pd.DataFrame, unit_mapping: dict = UNITS_MAPPING) -> pd.Series | pd.DataFrame
Remaps unit index to standard value for statistics with need for direct comparison of input-output flows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
series
|
Series | DataFrame
|
A series with a MultiIndex with a |
required |
unit_mapping
|
dict
|
Dictionary with old unit values as keys and new unit values as values, by default UNITS_MAPPING |
UNITS_MAPPING
|
Returns:
| Type | Description |
|---|---|
Series | DataFrame
|
A series with a MultiIndex with a |
get_energy_totals_domestic_share(energy_totals: Path, kind: str) -> pd.Series
Return the domestic share of energy totals for a given kind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy_totals
|
Path
|
Path to the energy totals csv file. |
required |
kind
|
str
|
The kind of energy totals to calculate the factor for. |
required |
Returns:
| Type | Description |
|---|---|
Series
|
The share of national aviation or navigation per country. |
create_location_index_from_copperplate(raw_input: pd.Series | pd.DataFrame, usage_location_list: list, column_name: str = 'location')
Replace the values of level column_name of an indexed object. Default
column_name to be replaced is "location" for backward compatibility.
This helper rebuilds the index of raw_input from its index frame and
overwrites the column_name column with values from
usage_location_list. It is mainly used when location information from
a copperplate-carrier result must be mapped back to explicit regional labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_input
|
Series or DataFrame
|
Input object with a (Multi)Index that includes a |
required |
usage_location_list
|
list
|
New location values to assign row-by-row. Must have the same length as
|
required |
column_name
|
str
|
Name of the index level to replace, by default "location". |
'location'
|
Returns:
| Type | Description |
|---|---|
Series or DataFrame
|
A copy of |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
ValueError
|
If |