timeseriesx.base package

Submodules

timeseriesx.base.base_time_series module

class timeseriesx.base.base_time_series.BaseTimeSeries[source]

Bases: object

aggregate(func)[source]

aggregate all values of the series with a custom aggregation function

Parameters

func (function) – a function mapping a numeric list/array/vector to a scalar

Returns

the aggregated value

Return type

numpy.float/numpy.int

append(value)[source]
abstract as_dict(ordered=False)[source]
as_pd_series(include_nan=True)[source]
abstract as_tuples()[source]
property empty
property first
join(other_ts, fit=True)[source]
property last
map(func, **kwargs)[source]

apply a custom function to each value of the series

Parameters

func (function) – a function mapping a scalar to another scalar

Returns

self

Return type

BaseTimeSeries

mean()[source]
prepend(value)[source]
round(decimals)[source]
sum()[source]
property values

timeseriesx.base.timestamp_series module

exception timeseriesx.base.timestamp_series.TimestampMismatchWarning[source]

Bases: RuntimeWarning

warning about implicit handling of mismatching timestamps

class timeseriesx.base.timestamp_series.TimestampSeries(series, freq=None, unit=None, time_zone=None)[source]

Bases: timeseriesx.mixins.unit.UnitMixin, timeseriesx.mixins.time_zone.TimeZoneMixin, timeseriesx.mixins.frequency.FrequencyMixin, timeseriesx.base.base_time_series.BaseTimeSeries

append(value)[source]

append a new value to a series with frequency

Parameters

value (float/int) – the value to append

Returns

the series with the new appended value

Return type

TimestampSeries

as_dict(ordered=False)[source]
as_time_period_series(align_left=True)[source]
as_tuples()[source]
static create_constant_timeseries(start, end, value, freq, unit=None, time_zone='infer')[source]

create a TimestampSeries-object from start to end with constant value

Parameters
  • start (str/datetime.datetime/pandas.Timestamp) – the start timestamp of the series (included)

  • end (str/datetime.datetime/pandas.Timestamp) – the end timestamp of the series (included)

  • value (int/float) – the constant value for each element

  • freq (str/datetime.timedelta/pandas.Offset/pandas.Timedelta) – the frequency of the timestamp series, pandas offset aliases supported

  • unit (str/pint.Unit) – the unit of the series’s values, many string representations of common units are supported, such as m, s, kg and many more

  • time_zone (str/tzinfo) – the name of the time zone, (see IANA) or a tzinfo-object, pass ‘infer’ if you want the time zone to be derived from start and end

Returns

a new TimestampSeries-object

Return type

TimestampSeries

static create_from_dict(dictionary, freq='infer', unit=None, time_zone='infer')[source]

create a TimestampSeries-object from a dict timestamps as keys and values as values

Parameters
  • dictionary (dict) – dict with timestamps as keys and timeseries-values as dict-values

  • freq (str/datetime.timedelta/pandas.Offset/pandas.Timedelta) –

    the frequency of the timestamp series, pandas offset aliases supported, pass ‘infer’ if you want the frequency to be derived by the timestamps

  • unit (str/pint.Unit) – the unit of the series’s values, many string representations of common units are supported, such as m, s, kg and many more

  • time_zone (str/tzinfo) –

    the name of the time zone, (see IANA) or a tzinfo-object, pass ‘infer’ if you want the time zone to be derived by the timestamps

Returns

a new TimestampSeries-object

Return type

TimestampSeries

static create_from_lists(timestamps, values, freq='infer', unit=None, time_zone='infer')[source]

create a TimestampSeries-object from a list of timestamps and values matched by their index

Parameters
  • timestamps (list) – the timestamps of the series

  • values (list) – the values of the series

  • freq (str/datetime.timedelta/pandas.Offset/pandas.Timedelta) –

    the frequency of the timestamp series, pandas offset aliases supported, pass ‘infer’ if you want the frequency to be derived by the timestamps

  • unit (str/pint.Unit) – the unit of the series’s values, many string representations of common units are supported, such as m, s, kg and many more

  • time_zone (str/tzinfo) –

    the name of the time zone, (see IANA) or a tzinfo-object, pass ‘infer’ if you want the time zone to be derived by the timestamps

Returns

a new TimestampSeries-object

Return type

TimestampSeries

static create_from_pd_series(series, freq='infer', unit=None, time_zone='infer')[source]

create a TimestampSeries-object from a pandas Series with DatetimeIndex

Parameters
  • pandas.Series – a pandas series-object with DatetimeIndex

  • freq (str/datetime.timedelta/pandas.Offset/pandas.Timedelta) –

    the frequency of the timestamp series, pandas offset aliases supported, pass ‘infer’ if you want the frequency to be derived by the timestamps

  • unit (str/pint.Unit) – the unit of the series’s values, many string representations of common units are supported, such as m, s, kg and many more

  • time_zone (str/tzinfo) –

    the name of the time zone, (see IANA) or a tzinfo-object, pass ‘infer’ if you want the time zone to be derived from start and end

Returns

a new TimestampSeries-object

Return type

TimestampSeries

static create_from_tuples(tuples, freq='infer', unit=None, time_zone='infer')[source]

create a TimestampSeries-object from a list of tuples of timestamps and values

Parameters
  • tuples (list) – list of tuples holding timestamp and value

  • freq (str/datetime.timedelta/pandas.Offset/pandas.Timedelta) –

    the frequency of the timestamp series, pandas offset aliases supported, pass ‘infer’ if you want the frequency to be derived by the timestamps

  • unit (str/pint.Unit) – the unit of the series’s values, many string representations of common units are supported, such as m, s, kg and many more

  • time_zone (str/tzinfo) –

    the name of the time zone, (see IANA) or a tzinfo-object, pass ‘infer’ if you want the time zone to be derived by the timestamps

Returns

a new TimestampSeries-object

Return type

TimestampSeries

static create_null_timeseries(start, end, freq, unit=None, time_zone='infer')[source]

create a TimestampSeries-object from start to end with NaN-values

Parameters
  • start (str/datetime.datetime/pandas.Timestamp) – the start timestamp of the series (included)

  • end (str/datetime.datetime/pandas.Timestamp) – the end timestamp of the series (included)

  • freq (str/datetime.timedelta/pandas.Offset/pandas.Timedelta) –

    the frequency of the timestamp series, pandas offset aliases supported

  • unit (str/pint.Unit) – the unit of the series’s values, many string representations of common units are supported, such as m, s, kg and many more

  • time_zone (str/tzinfo) –

    the name of the time zone, (see IANA) or a tzinfo-object, pass ‘infer’ if you want the time zone to be derived from start and end

Returns

a new TimestampSeries-object

Return type

TimestampSeries

property end
property first
join(other_ts, fit=True)[source]
property last
map(func, dimensionless=True)[source]

apply a custom function to each value of the series

Parameters
  • func (function) – a function mapping a scalar to another scalar

  • dimensionless (bool) – if set to True, the mapping function takes an argument of type Number (no unit, dimensionless). The resulting timestamp series will keep the original unit. If set to False, the mapping function takes an argument of type pint.Quantity. The resulting timestamp series will have the unit of the mapped values. Mapping values of one series to different units results in an error. Mapping with dimensionless=False will result in a loop and therefore perform slower.

Returns

the series with mapped values

Return type

TimestampSeries

prepend(value)[source]

prepend a new value to a series with frequency

Parameters

value (float/int) – the value to prepend

Returns

the series with the new prepended value

Return type

TimestampSeries

round(decimals)[source]

round the values of the series

Parameters

decimals – no of decimal places to round to

Returns

the series with rounded values

Return type

TimestampSeries

property start
property time_range
property timestamps
validate_all()[source]
property values

Module contents