pyam

Package documentation

genno.compat.pyam.computations.as_pyam(scenario, quantity, replace={}, year_time_dim=None, rename={}, collapse: Optional[Callable] = None, drop: Union[Collection[str], str] = 'auto', unit=None)

Return a pyam.IamDataFrame containing quantity.

Warnings are logged if the arguments result in additional, unhandled columns in the resulting data frame that are not part of the IAMC spec.

Raises

ValueError – If the resulting data frame has duplicate values in the standard IAMC index columns. pyam.IamDataFrame cannot handle this data.

genno.compat.pyam.computations.concat(*args, **kwargs)

Concatenate args, which must all be pyam.IamDataFrame.

genno.compat.pyam.computations.write_report(quantity, path)

Write the report identified by key to the file at path.

If quantity is a pyam.IamDataFrame and path ends with ‘.csv’ or ‘.xlsx’, use pyam methods to write the file to CSV or Excel format, respectively. Otherwise, equivalent to genno.computations.write_report().

genno.compat.pyam.util.clean_units(df: pandas.core.frame.DataFrame, unit=None) → pandas.core.frame.DataFrame

Convert magnitudes and units of df to unit in str.

Raises

ValueError – if there is more than one unit.

genno.compat.pyam.util.collapse(df: pandas.core.frame.DataFrame, columns: Dict[str, str] = {}, sep='|') → pandas.core.frame.DataFrame

Collapse columns into the IAMC columns of df.

genno.compat.pyam.util.drop(df: pandas.core.frame.DataFrame, columns: Union[Collection[str], str]) → pandas.core.frame.DataFrame

Drop columns if given, or all non-IAMC columns.

Configuration

compat.pyam adds a iamc: configuration file section.

pyam.iamc(info)

Handle one entry from the iamc: config section.

Computer-specific configuration.

Invokes Computer.convert_pyam() (plus extra computations) to reformat data from Quantity into a pyam.IamDataFrame data structure. Each entry contains:

  • variable (str): variable name. This is used two ways: it is placed in ‘Variable’ column of the resulting IamDataFrame; and the reporting key to get() the data frame is <variable>:iamc.

  • base (str): key for the quantity to convert.

  • select (dict, optional): keyword arguments to computations.select().

  • group_sum (2-tuple, optional): group and sum arguments to computations.group_sum().

  • year_time_dim (str, optional): Dimension to use for the IAMC ‘Year’ or ‘Time’ column. Default ‘ya’. (Passed to convert_pyam().)

  • drop (list of str, optional): Dimensions to drop (→ convert_pyam).

  • unit (str, optional): Force output in these units (→ convert_pyam).

Additional entries are passed as keyword arguments to collapse(), which is then given as the collapse callback for convert_pyam().

collapse() formats the ‘Variable’ column of the IamDataFrame. The variable name replacements from the iamc variable names: section of the config file are applied to all variables.