Loading...

vastorbit.VastFrame.between_time

VastFrame.between_time(ts: str, start_time: Annotated[str | timedelta, 'Time Interval'] | None = None, end_time: Annotated[str | timedelta, 'Time Interval'] | None = None, inplace: bool = True) VastFrame

Filters the VastFrame by only keeping the records between two input times.

Parameters:
  • ts (str) – TS (Time Series) VastColumn used to filter the data. The VastColumn type must be date (date, datetime, timestamp…).

  • start_time (TimeInterval) – Input Start Time. For example, time = ‘12:00’ will filter the data when time(‘ts’) is lesser than 12:00.

  • end_time (TimeInterval) – Input End Time. For example, time = ‘14:00’ will filter the data when time(‘ts’) is greater than 14:00.

  • inplace (bool, optional) – If set to True, the filtering is applied to the VastFrame.

Returns:

self

Return type:

VastFrame

Examples

We import vastorbit:

import vastorbit as vo

Hint

By assigning an alias to vastorbit, we mitigate the risk of code collisions with other libraries. This precaution is necessary because vastorbit 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 vastorbit are used as intended without interfering with functions from other libraries.

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

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:03",
            "1993-11-03 00:00:04",
            "1993-11-04 00:00:01",
            "1993-11-04 00:00:02",
        ],
        "val": [0., 1., 2., 4., 5., 3., 2.],
    }
)["time"].astype("timestamp")
📅
time
Timestamp(3)
123
val
Decimal(2, 1)
11993-11-03 00:00:034.0
21993-11-04 00:00:022.0
31993-11-03 00:00:045.0
41993-11-04 00:00:013.0
51993-11-03 00:00:022.0
61993-11-03 00:00:000.0
71993-11-03 00:00:011.0
Rows: 1-7 | Columns: 2

Note

vastorbit 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 vastorbit environment.

Using between_time we can easily filter through time-series values:

vdf.between_time(ts= "time", start_time= "00:00:01", end_time = "00:00:03")
📅
time
Timestamp(3)
123
val
Decimal(2, 1)
11993-11-03 00:00:011.0
21993-11-04 00:00:013.0
31993-11-03 00:00:034.0
41993-11-03 00:00:022.0
51993-11-04 00:00:022.0
Rows: 5 | Columns: 2

Notice that the function ignores the dates, and outputs all the times in that range. This is because it is only using the time information from ts column and ignoring the date information.

See also

VastFrame.between() : Filters between two conditions.
VastFrame.at_time() : Filters the VastFrame at a specific time.