Loading...

verticapy.vDataFrame.at_time#

vDataFrame.at_time(ts: str, time: str | timedelta) vDataFrame#

Filters the vDataFrame by only keeping the records at the input time.

Parameters#

ts: str

TS (Time Series) vDataColumn used to filter the data. The vDataColumn type must be date (date, datetime, timestamp…).

time: TimeInterval

Input Time. For example, time = ‘12:00’ will filter the data when time(‘ts’) is equal to 12:00.

Returns#

vDataFrame

self

Examples#

We import verticapy:

import verticapy as vp

Hint

By assigning an alias to verticapy, we mitigate the risk of code collisions with other libraries. This precaution is necessary because verticapy uses commonly known function names like “average” and “median”, which can potentially lead to naming conflicts. The use of an alias ensures that the functions from verticapy are used as intended without interfering with functions from other libraries.

For this example, we will use a dummy time-series data:

vdf = vp.vDataFrame(
    {
        "time": [
            "1993-11-03 00:00:00",
            "1993-11-03 00:00:01",
            "1993-11-03 00:00:02",
            "1993-11-04 00:00:01",
            "1993-11-04 00:00:02",
        ],
        "val": [0., 1., 2., 4., 5.],
    }
)

Abc
time
Varchar(19)
100%
123
val
Numeric(4)
100%
11993-11-03 00:00:000.0
21993-11-03 00:00:011.0
31993-11-03 00:00:022.0
41993-11-04 00:00:014.0
51993-11-04 00:00:025.0

Note

VerticaPy offers a wide range of sample datasets that are ideal for training and testing purposes. You can explore the full list of available datasets in the Datasets, which provides detailed information on each dataset and how to use them effectively. These datasets are invaluable resources for honing your data analysis and machine learning skills within the VerticaPy environment.

In the above data, we have values for two dates. We can use the at_time filter to get the required time-stamp values:

vdf.at_time(ts = "time", time = "00:00:01")
Abc
time
Varchar(19)
100%
123
val
Numeric(4)
100%
11993-11-03 00:00:011.0
21993-11-04 00:00:014.0

See also

vDataFrame.balance() : Balances the vDataFrame.
vDataFrame.between() : Filters between two conditions.