vastorbit.VastFrame.interpolate¶
- VastFrame.interpolate(ts: str, rule: Annotated[str | timedelta, 'Time Interval'], method: dict | None = None, by: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None) VastFrame¶
Computes a regular time interval VastFrame by interpolating the missing values using different techniques.
- Parameters:
ts (str) – TS (Time Series) VastColumn used to order the data. The VastColumn type must be date (date, datetime, timestamp…).
rule (TimeInterval) – Interval used to create the time slices. The final interpolation is divided by these intervals. For example, specifying ‘5 minutes’ creates records separated by time intervals of ‘5 minutes’. Format: ‘1 second’, ‘5 minutes’, ‘1 hour’, ‘1 day’, etc.
method (dict, optional) –
Dictionary of interpolation methods. Must be in the following format: {“column1”: “interpolation1” …, “columnk”: “interpolationk”} Interpolation methods must be one of the following:
- bfill/backfill:
Interpolates with the next non-null value.
- ffill/pad:
Interpolates with the previous non-null value.
- linear:
Linear interpolation between points.
by (SQLColumns, optional) – VastColumns used in the partition.
- Returns:
object result of the interpolation.
- Return type:
Examples
import vastorbit as vo vdf = vo.VastFrame({ "time": [ "1993-11-03 00:00:00", "1993-11-03 00:00:01", "1993-11-03 00:00:02", "1993-11-03 00:00:04", "1993-11-03 00:00:05", ], "val": [0., 1., 2., 4., 5.], }) vdf["time"].astype("timestamp") # Linear interpolation result = vdf.interpolate( ts="time", rule="1 second", method={"val": "linear"}, )