gs_quant.timeseries.algebra.subtract¶
- subtract(x, y, method=Interpolate.STEP)[source]¶
Add two series or scalars
- Parameters:
x (
Union
[Series
,Real
]) – timeseries or scalary (
Union
[Series
,Real
]) – timeseries or scalarmethod (
Interpolate
) – index alignment operator (default: intersect). Only used when both x and y are timeseries
- Return type:
Union
[Series
,Real
]- Returns:
timeseries of x - y or difference between the given real numbers
Usage
Subtracts one series or scalar from another applying the given interpolation method
\(R_t = X_t - Y_t\)
Alignment operators:
Method
Behavior
intersect
Resultant series only has values on the intersection of dates. Values for dates present in only one series will be ignored
nan
Resultant series has values on the union of dates in both series. Values for dates only available in one series will be treated as nan in the other series, and therefore in the resultant series
zero
Resultant series has values on the union of dates in both series. Values for dates only available in one series will be treated as zero in the other series
step
Resultant series has values on the union of dates in both series. Values for dates only available in one series will be interpolated via step function in the other series
time
Resultant series have values on the union of dates / times. Missing values surrounded by valid values will be interpolated given length of interval. Input series must use DateTimeIndex.
Examples
Subtract one series from another:
>>> a = generate_series(100) >>> b = generate_series(100) >>> subtract(a, b, Interpolate.STEP)
See also