operator¶
-
class
timeseries.operator.
_TimeSeriesOperator
(tseries)[source]¶ Bases:
object
Interface class for extending set operations to time series based on dates and applying functions to resulting time series.
- Parameters
tseries – time series to operate on
-
_apply
(func, arg, operation, elementwise, fill, **kwargs)[source]¶ Apply function to time series after set operation.
- Parameters
func – function to apply to time series
arg – time series or broadcasted argument passed to function
operation – set operation to apply to time series dates
elementwise – flag if function is applied elementwise and should return time series
fill – value to fill in missing dates
**kwargs – keyword arguments passed to function
-
classmethod
_apply_function
(tseries, arg, func, elementwise, **kwargs)[source]¶ Apply function to time series and return result, or results as timeseries if elementwise.
- Parameters
tseries – time series to operate on
arg – time series or broadcasted argument passed to function
func – function to apply to time series
elementwise – flag if function is applied elementwise and should return time series
**kwargs – keyword arguments passed to function
-
static
_broadcast
(value, size)[source]¶ Return value broadcasted to tuple.
- Parameters
value – float-convertable value
size – size of tuple
-
classmethod
_fill_tseries
(dates, tseries, fill)[source]¶ Return time series in specified dates with missing values filled.
- Parameters
tseries – time series object to extend or contract
dates – dates to keep and fill if missing
fill – value to fill in missing dates
-
custom
(func, arg, operation='intersection', elementwise=True, fill=0, **kwargs)[source]¶ Apply custom function to time series after set operation.
- Parameters
func – function to apply to time series
arg – time series or broadcasted argument passed to function
operation – set operation to apply to time series dates, defaults to ‘intersection’
elementwise – flag if function is applied elementwise and should return time series, defaults to True
fill – value to fill in missing dates, defaults to 0
**kwargs – keyword arguments passed to function
-
timeseries.operator.
add
(values1, values2)[source]¶ Return the element-wise sum of two numeric iterables.
- Parameters
values1 – finite-length iterable of float-convertable numbers
values2 – finite-length iterable of float-convertable numbers
-
timeseries.operator.
subtract
(values1, values2)[source]¶ Return element-wise difference of two numeric iterables.
- Parameters
values1 – finite-length iterable of float-convertable numbers
values2 – finite-length iterable of float-convertable numbers to subtract
-
timeseries.operator.
multiply
(values1, values2)[source]¶ Return element-wise multiplication of two numeric iterables.
- Parameters
values1 – finite-length iterable of float-convertable numbers
values2 – finite-length iterable of float-convertable numbers
-
timeseries.operator.
divide
(values1, values2)[source]¶ Return element-wise division of two numeric iterables.
- Parameters
values1 – finite-length iterable of float-convertable numbers
values2 – finite-length iterable of float-convertable numbers to divide with
-
timeseries.operator.
right_divide
(values1, values2)[source]¶ Return element-wise right division of two numeric iterables.
- Parameters
values1 – finite-length iterable of float-convertable numbers to divide with
values2 – finite-length iterable of float-convertable numbers