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

Parameters
datapandas.Series 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