timeseriesx.mixins package
Submodules
timeseriesx.mixins.frequency module
- class timeseriesx.mixins.frequency.FrequencyMixin(*args, **kwargs)[source]
Bases:
timeseriesx.mixins.BaseMixin
- fill_gaps(start=None, end=None, value=nan)[source]
fill all gaps between start and end in a series with a frequency with a constant value
- Parameters
start (datetime.datetime) – the start timestamps of the period that will be investigated (included). If None, then the first timestamp in the time series is considered as start. Defaults to None
end (datetime.datetime) – the end timestamps of the period that will be investigated (included). If None, then the last timestamp in the time series is considered as end. Defaults to None
value (float/int/np.float) – the constant fill value
- Returns
return the series with filled gaps
- Return type
- property freq
- get_gaps(start=None, end=None)[source]
get all timestamps between start and end from a series with a frequency, where the value is missing or NaN
- Parameters
start (datetime.datetime) – the start timestamps of the period that will be investigated (included). If None, then the first timestamp in the time series is considered as start. Defaults to None
end (datetime.datetime) – the end timestamps of the period that will be investigated (included). If None, then the last timestamp in the time series is considered as end. Defaults to None
- Returns
list of timestamps
- Return type
list of datetime.datetime
- resample(freq, method)[source]
resample the series to a smaller frequency, aggregate the values
- Parameters
freq (str/datetime.timedelta/pandas.Offset/pandas.Timedelta) – the new frequency, has to be smaller than the current frequency (greater offset)
method (str/Callable) – aggregation method, currently supported are “all”, “any”, “min”, “max”, “sum”, “mean”, “median”, or function that a collection (e.g. pandas.Series or list) of numeric values as its argument and returns a scalar
- Returns
the resamples time series
- Return type
timeseriesx.mixins.time_zone module
- class timeseriesx.mixins.time_zone.TimeZoneMixin(*args, **kwargs)[source]
Bases:
timeseriesx.mixins.BaseMixin
- convert_time_zone(tz)[source]
convert time series index to another time zone, or make an time zone naive index time zone aware (or the other way round)
- Parameters
tz (str/datetime.tzinfo) – tzinfo object or name of the new time zone or None
- Returns
the series with converted index
- Return type
- property time_zone
timeseriesx.mixins.unit module
- class timeseriesx.mixins.unit.UnitMixin(*args, **kwargs)[source]
Bases:
timeseriesx.mixins.BaseMixin
- aggregate(func, with_unit=False)[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
with_unit (boolean) – flag whether to return the result as a pint object, defaults to False
- Returns
the aggregated value
- Return type
numpy.float/numpy.int/pint.Quantity
- convert_unit(unit)[source]
convert the unit of the series
- Parameters
unit (str/pint.Unit) –
- Returns
the time series with converted units
- Return type
- mean(with_unit=False)[source]
calculate the mean of all values of the series
- Parameters
with_unit (boolean) – flag whether to return the result as a pint object, defaults to False
- Returns
the mean of the values
- Return type
numpy.float/numpy.int/pint.Quantity
- sum(with_unit=False)[source]
calculate the sum of all values of the series
- Parameters
with_unit (boolean) – flag whether to return the result as a pint object, defaults to False
- Returns
the sum of the values
- Return type
numpy.float/numpy.int/pint.Quantity
- property unit