gs_quant.timeseries.datetime.align¶
- align(x, y, method=Interpolate.INTERSECT)[source]¶
Align dates of two series or scalars
- Parameters:
x (
Union
[Series
,Real
]) – first timeseries or scalary (
Union
[Series
,Real
]) – second timeseries or scalarmethod (
Interpolate
) – interpolation method (default: intersect). Only used when both x and y are timeseries
- Return type:
Union
[List
[Series
],List
[Real
]]- Returns:
timeseries with specified dates or two scalars from the input
Usage
Align the dates of two series using the specified interpolation method. Returns two series with dates based on the method of interpolation, for example, can be used to intersect the dates of two series, union dates with a defined manner to compute missing values.
Interpolation methods:
Type
Behavior
intersect
Resultant series only have values on the intersection of dates /times.
nan
Resultant series have values on the union of dates /times. Values will be NaN for dates or times only present in the other series
zero
Resultant series have values on the union of dates / times. Values will be zero for dates or times only present in the other series
step
Resultant series have values on the union of dates / times. Each series will use the value of the previous valid point if requested date does not exist. Values prior to the first date will be equivalent to the first available value
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
Stepwize interpolation of series based on dates in second series:
>>> a = generate_series(100) >>> b = generate_series(100) >>> align(a, b)
See also
sub()