Variables utilities

The variable dimension of the pyam data format implements implements a “semi-hierarchical” structure using the | character (pipe, not l or i) to indicate the depth. Read the data model documentation for more information.

The package provides several functions to work with such strings.

pyam.concat_with_pipe(x, cols=None)[source]

Concatenate a pandas.Series x using |, drop None or numpy.nan

pyam.find_depth(data, s='', level=None)[source]

Return or assert the depth (number of |) of variables

datastr or list of strings

IAMC-style variables

sstr, default ‘’

remove leading s from any variable in data

levelint or str, default None

if None, return depth (number of |); else, return list of booleans whether depth satisfies the condition (equality if level is int, >= if .+, <= if .-)

pyam.reduce_hierarchy(x, depth)[source]

Reduce the hierarchy (indicated by |) of x to the specified depth

pyam.get_variable_components(x, level, join=False)[source]

Return components for requested level in a list or join these in a str.


Uses | to separate the components of the variable.

levelint or list of int

Position of the component.

joinbool or str, optional

If True, IAMC-style (|) is used as separator for joined components.