vDataFrame.interpolate¶
In [ ]:
vDataFrame.interpolate(ts: str,
rule: (str, datetime.timedelta),
method: dict,
by: list = [])
Computes a regular time interval vDataFrame by interpolating the missing values using different techniques.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
ts | str | ❌ | TS (Time Series) vcolumn to use to order the data. The vcolumn type must be date like (date, datetime, timestamp...) |
rule | str / time | ❌ | 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'. |
method | dict | ❌ | Dictionary, with the following format, of interpolation methods: {"column1": "interpolation1" ..., "columnk": "interpolationk"}. Interpolation methods must be one of the following:
|
by | list | ✓ | vcolumns used in the partition. |
Returns¶
vDataFrame : object result of the interpolation.
Example¶
In [26]:
from verticapy import tablesample
ts = tablesample({"datetime": ["1993-11-03 00:00:00",
"1993-11-03 00:00:01",
"1993-11-03 00:00:02",
"1993-11-03 00:00:03",
"1993-11-03 00:00:04",
"1993-11-03 00:00:05",
"1993-11-03 00:01:01",
"1993-11-03 00:01:02",
"1993-11-03 00:01:03",
"1993-11-03 00:01:04",
"1993-11-03 00:01:05",],
"val": [0., 1., 2., 3., 4., 5., 61., 62., 63., 64., 65.,]})
ts = ts.to_vdf()
ts["datetime"].astype("datetime")
display(ts)
In [36]:
# Linear interpolation by second
ts.interpolate(ts = "datetime",
rule = "1 second",
method = {"val": "linear"},)
Out[36]:
In [37]:
# First fill interpolation by second
ts.interpolate / asfreq(ts = "datetime",
rule = "1 second",
method = {"val": "ffill"},)
Out[37]:
In [42]:
# Back fill interpolation by 3 seconds
# Back fill uses the final value of each block. With gaps, the behavior
# can be similar to first fill
ts.interpolate(ts = "datetime",
rule = "2 seconds",
method = {"val": "bfill"},)
Out[42]:
See Also¶
vDataFrame[].fillna | Fills the vcolumn missing values. |
vDataFrame[].slice | Slices the vcolumn. |