pymrio.Extension.characterize
- Extension.characterize(factors, characterized_name_column='impact', characterization_factors_column='factor', characterized_unit_column='impact_unit', orig_unit_column='stressor_unit', only_validation=False, name='_characterized')
Characterize stressors.
Characterizes the extension with the characterization factors given in factors.
The dataframe factors can contain characterization factors which depend on stressors not present in the Extension - these will be ignored (set to 0).
The dataframe passed for the characterization must be in a long format. It must contain columns with the same names as in the index of the extension.
The routine can also handle region or sector specific characterization factors. In that case, the passed dataframe must also include columns for sector and/or region. The names must be the same as the column names of the extension.
Other column names can be specified in the parameters, see below for the default values.
The routine also performs a validation of the input factors DataFrame and reports
- unit errors (impact unit consistent, stressor unit match).
Note: does not check if the conversion is correct!
- report missing stressors, regions, sectors which are in factors
but not in the extension
if factors are specified for all regions/sectors of the extension
Besides the unit errors, the characterization routine works with missing data. Any missing data is assumed to be 0.
Note
Accordance of units is enforced. This is done be checking the column specified in orig_unit_column with the unit dataframe of the extension.
- Parameters
factors (pd.DataFrame) – A dataframe in long format with numerical index and columns named index.names of the extension to be characterized and ‘characterized_name_column’, ‘characterization_factors_column’, ‘characterized_unit_column’, ‘orig_unit_column’
characterized_name_column (str (optional) or list[str]) – Name of the column with the names of the characterized account (default: “impact”). In case a list of columns is passed, these get conconateded to one colum and split before return.
characterization_factors_column (str (optional)) – Name of the column with the factors for the characterization (default: “factor”)
characterized_unit_column (str (optional)) – Name of the column with the units of the characterized accounts characterization (default: “impact_unit”)
name (string (optional)) – The new name for the extension, if the string starts with an underscore ‘_’ the string with be appended to the original name. Default: ‘_characterized’
- Returns
namedtuple with the following attributes – validation: pd.DataFrame extension: pymrio.Extension
Extension is set to None when “only_validation” is set to True.