# Timeseries utilities¶

The pyam package includes several utility functions for working with timeseries data formatted as pandas.Series that have the time dimension as index.

Warning

Not all pyam functions currently support continuous-time formats. Please reach out via our mailing list or GitHub issues if you are not sure whether your use case is supported.

pyam.cumulative(x, first_year, last_year)[source]

Returns the cumulative sum of a timeseries

This function implements linear interpolation between years and ignores nan’s in the range. The function includes the last-year value of the series, and raises a warning if start_year or last_year is outside of the timeseries range and returns nan

Parameters
xpandas.Series

a timeseries to be summed over time

first_yearint

first year of the sum

last_yearint

last year of the sum (inclusive)

pyam.fill_series(x, time)[source]

Returns the timeseries value at a point in time by linear interpolation

Parameters
xpandas.Series

a timeseries to be interpolated

timeint or pandas.datetime

year or datetime to interpolate

pyam.cross_threshold(x, threshold=0, direction=['from above', 'from below'])[source]

Returns a list of the years in which a timeseries crosses a threshold

Parameters
xpandas.Series

a timeseries indexed over years

thresholdfloat, default 0

the threshold that the timeseries is checked against

directionstr, optional, default [‘from above’, ‘from below’]

whether to return all years where the threshold is crossed or only where threshold is crossed in a specific direction