vDataFrame.between_time

In [ ]:
vDataFrame.between_time(ts: str, 
                        start_time: (str, datetime.timedelta), 
                        end_time: (str, datetime.timedelta))

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

Parameters

Name Type Optional Description
ts
str
❌
TS (Time Series) vcolumn to use to filter the data. The vcolumn type must be date like (date, datetime, timestamp...)
start_time
str / time
❌
Input Start Time. For example, time = '12:00' will filter the data when time('ts') is lesser than 12:00.
end_time
str / time
❌
Input End Time. For example, time = '14:00' will filter the data when time('ts') is greater than 14:00.

Returns

vDataFrame : self

Example

In [126]:
from verticapy.datasets import load_smart_meters
sm = load_smart_meters()
display(sm)
123
val
Numeric(11,7)
📅
time
Timestamp
123
id
Int
10.03700002014-01-01 01:15:002
20.08000002014-01-01 02:30:005
30.08100002014-01-01 03:00:001
41.48900002014-01-01 05:00:003
50.07200002014-01-01 06:00:005
62.30600002014-01-01 07:15:009
70.10200002014-01-01 07:45:004
80.09700002014-01-01 10:45:008
90.02900002014-01-01 11:00:000
100.50600002014-01-01 11:00:006
110.12900002014-01-01 11:15:005
120.62200002014-01-01 13:00:004
130.27700002014-01-01 13:45:000
140.23500002014-01-01 15:30:009
150.62300002014-01-01 16:45:007
161.35000002014-01-01 17:00:005
170.55900002014-01-01 17:15:001
180.37500002014-01-01 19:15:001
190.54000002014-01-01 22:30:009
200.35800002014-01-02 00:30:002
210.13900002014-01-02 01:30:003
220.05500002014-01-02 02:45:003
230.08600002014-01-02 03:00:006
240.04400002014-01-02 03:30:001
250.07300002014-01-02 03:45:008
260.10000002014-01-02 04:45:007
270.04400002014-01-02 05:30:001
280.04800002014-01-02 06:45:001
290.05500002014-01-02 06:45:005
300.08200002014-01-02 10:15:001
310.32100002014-01-02 10:45:000
320.30500002014-01-02 11:15:000
330.39700002014-01-02 12:30:005
340.35800002014-01-02 13:45:000
350.25400002014-01-02 14:30:004
360.11500002014-01-02 15:30:000
370.18500002014-01-02 15:30:007
380.52400002014-01-02 16:00:008
390.87100002014-01-02 17:45:004
401.03800002014-01-02 19:30:009
411.47800002014-01-02 19:45:006
421.77600002014-01-02 20:15:008
430.09400002014-01-03 00:30:008
440.31300002014-01-03 00:45:006
450.13300002014-01-03 01:45:009
460.06000002014-01-03 02:45:006
470.08500002014-01-03 03:15:009
480.06600002014-01-03 04:30:003
490.06800002014-01-03 04:30:001
500.06700002014-01-03 05:45:008
510.03200002014-01-03 06:30:007
520.08400002014-01-03 07:45:009
530.27200002014-01-03 07:45:002
540.07100002014-01-03 08:30:000
551.50600002014-01-03 09:15:004
560.07400002014-01-03 10:30:009
572.10800002014-01-03 11:00:004
580.10300002014-01-03 12:15:008
590.48900002014-01-03 19:45:007
600.67200002014-01-03 21:30:007
610.59100002014-01-03 22:15:005
621.93800002014-01-03 22:15:001
630.28400002014-01-03 23:30:004
640.13100002014-01-04 01:15:006
651.54600002014-01-04 01:30:001
660.36100002014-01-04 01:45:006
670.38300002014-01-04 02:15:006
680.18500002014-01-04 02:45:005
690.06200002014-01-04 05:45:008
700.26700002014-01-04 06:00:005
710.07700002014-01-04 06:45:008
720.06800002014-01-04 07:30:002
730.30900002014-01-04 07:45:004
740.15300002014-01-04 10:00:008
750.54500002014-01-04 10:45:007
761.26800002014-01-04 11:45:008
770.07600002014-01-04 12:00:002
781.36000002014-01-04 13:30:008
790.28500002014-01-04 17:15:002
800.44700002014-01-04 17:15:009
810.64100002014-01-04 18:00:004
820.82700002014-01-04 22:30:004
830.32300002014-01-04 23:45:000
840.30500002014-01-05 02:15:006
850.11100002014-01-05 04:00:009
860.07500002014-01-05 06:30:009
870.09000002014-01-05 08:00:004
880.16000002014-01-05 08:45:009
890.28100002014-01-05 10:00:003
900.58000002014-01-05 10:15:006
911.13200002014-01-05 11:30:006
920.62500002014-01-05 17:30:004
930.53700002014-01-05 19:45:004
940.54600002014-01-05 19:45:001
950.53900002014-01-05 23:30:009
960.08500002014-01-06 01:15:000
970.08700002014-01-06 02:45:008
980.06900002014-01-06 05:00:003
990.02700002014-01-06 07:45:003
1000.53000002014-01-06 07:45:002
Rows: 1-100 of 11844 | Columns: 3
In [127]:
sm.between_time(ts = "time", start_time = "12:00", end_time = "14:00")
10693 element(s) was/were filtered
123
val
Numeric(11,7)
📅
time
Timestamp
123
id
Int
10.62200002014-01-01 13:00:004
20.27700002014-01-01 13:45:000
30.39700002014-01-02 12:30:005
40.35800002014-01-02 13:45:000
50.10300002014-01-03 12:15:008
60.07600002014-01-04 12:00:002
71.36000002014-01-04 13:30:008
80.08700002014-01-07 13:15:003
90.46900002014-01-07 14:00:006
100.27200002014-01-08 13:15:007
110.16100002014-01-09 12:00:006
120.41000002014-01-09 12:30:005
130.12500002014-01-09 14:00:008
140.29800002014-01-10 12:15:006
150.48900002014-01-11 12:45:004
160.05300002014-01-11 13:00:008
1711.40500002014-01-12 12:15:006
180.06000002014-01-13 12:15:004
190.07200002014-01-13 12:45:001
200.04100002014-01-13 13:15:004
210.02000002014-01-13 13:30:007
220.09900002014-01-14 13:00:000
230.20000002014-01-14 14:00:000
240.04900002014-01-15 12:00:009
250.04500002014-01-16 12:30:004
260.26300002014-01-16 12:45:001
270.51300002014-01-16 12:45:002
280.12800002014-01-18 13:45:005
290.02000002014-01-19 12:00:004
300.12000002014-01-19 14:00:002
310.13900002014-01-19 14:00:008
320.78100002014-01-20 12:15:007
330.17200002014-01-20 12:45:008
341.08500002014-01-20 12:45:007
350.14400002014-01-21 12:00:007
360.32700002014-01-21 12:30:000
370.10800002014-01-21 13:30:000
381.20300002014-01-21 13:30:006
390.19700002014-01-22 13:30:002
400.16800002014-01-24 12:15:000
410.07000002014-01-25 12:45:005
420.26300002014-01-26 12:15:003
430.19300002014-01-26 13:00:001
440.32300002014-01-27 12:00:004
450.48100002014-01-28 13:45:008
461.71900002014-01-29 13:00:000
471.00900002014-01-30 12:15:006
482.44500002014-01-30 13:30:006
490.13500002014-01-31 13:15:002
501.64600002014-01-31 13:45:001
510.10400002014-02-01 12:00:007
521.23800002014-02-02 12:15:001
530.74400002014-02-02 13:30:004
540.60600002014-02-02 14:00:004
550.18700002014-02-04 12:00:000
560.05800002014-02-04 12:45:009
570.08800002014-02-04 13:15:009
580.67300002014-02-04 13:15:002
590.28600002014-02-04 13:45:002
600.05800002014-02-05 12:30:005
610.90300002014-02-05 12:45:003
620.05900002014-02-05 14:00:001
630.42400002014-02-06 12:30:005
640.14200002014-02-07 12:45:009
650.56000002014-02-09 13:30:009
660.02700002014-02-10 12:15:008
670.04900002014-02-11 12:00:009
680.15400002014-02-12 12:15:003
690.02500002014-02-12 12:45:001
700.03300002014-02-14 13:45:000
710.21800002014-02-15 12:15:007
720.11800002014-02-15 12:45:009
730.01700002014-02-15 13:15:002
740.26800002014-02-15 13:15:001
750.03100002014-02-15 13:45:000
760.08800002014-02-16 13:45:009
770.03500002014-02-17 12:45:006
780.04900002014-02-17 12:45:000
790.47100002014-02-17 13:15:005
800.11700002014-02-18 12:15:009
810.07100002014-02-18 12:45:009
820.15000002014-02-18 13:00:001
830.29000002014-02-19 12:00:009
840.29800002014-02-21 12:30:001
850.57100002014-02-21 13:15:000
860.23000002014-02-21 14:00:003
870.05600002014-02-22 13:30:003
880.17400002014-02-23 12:00:000
890.05700002014-02-23 12:45:005
900.06300002014-02-25 13:00:004
9114.60300002014-02-25 13:00:007
920.12400002014-02-26 12:00:008
930.38800002014-02-26 12:15:000
940.07800002014-02-26 13:30:007
950.06700002014-02-26 14:00:004
960.16400002014-02-27 14:00:004
970.11800002014-02-28 12:00:006
980.29900002014-02-28 12:00:002
990.03700002014-02-28 12:30:000
1000.39200002014-03-02 12:30:002
Out[127]:
Rows: 1-100 of 1151 | Columns: 3

See Also

vDataFrame.at_time Filters the data at the input time.
vDataFrame.first Filters the data by only keeping the first records.
vDataFrame.filter Filters the data using the input expression.
vDataFrame.last Filters the data by only keeping the last records.