vDataFrame[].slice

In [ ]:
vDataFrame[].slice(length: int, 
                   unit: str = "second", 
                   start: bool = True)

Slices the vcolumn using a TS rule. The vcolumn will be transformed.

Parameters

Name Type Optional Description
length
int
Slice size.
unit
str
Slice size unit. For example, it can be 'minute' 'hour'...
start
bool
If set to True, the record will be sliced using the floor of the slicing instead of the ceiling.

Returns

vDataFrame : self.parent

Example

In [70]:
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 [71]:
sm["time"].slice(length = 30,
                 unit = "minute")
123
val
Numeric(11,7)
📅
time
Datetime
123
id
Int
10.03700002014-01-01 01:00: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:00:009
70.10200002014-01-01 07:30:004
80.09700002014-01-01 10:30:008
90.02900002014-01-01 11:00:000
100.50600002014-01-01 11:00:006
110.12900002014-01-01 11:00:005
120.62200002014-01-01 13:00:004
130.27700002014-01-01 13:30:000
140.23500002014-01-01 15:30:009
150.62300002014-01-01 16:30:007
161.35000002014-01-01 17:00:005
170.55900002014-01-01 17:00:001
180.37500002014-01-01 19:00: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:30:003
230.08600002014-01-02 03:00:006
240.04400002014-01-02 03:30:001
250.07300002014-01-02 03:30:008
260.10000002014-01-02 04:30:007
270.04400002014-01-02 05:30:001
280.04800002014-01-02 06:30:001
290.05500002014-01-02 06:30:005
300.08200002014-01-02 10:00:001
310.32100002014-01-02 10:30:000
320.30500002014-01-02 11:00:000
330.39700002014-01-02 12:30:005
340.35800002014-01-02 13:30: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:30:004
401.03800002014-01-02 19:30:009
411.47800002014-01-02 19:30:006
421.77600002014-01-02 20:00:008
430.09400002014-01-03 00:30:008
440.31300002014-01-03 00:30:006
450.13300002014-01-03 01:30:009
460.06000002014-01-03 02:30:006
470.08500002014-01-03 03:00:009
480.06600002014-01-03 04:30:003
490.06800002014-01-03 04:30:001
500.06700002014-01-03 05:30:008
510.03200002014-01-03 06:30:007
520.08400002014-01-03 07:30:009
530.27200002014-01-03 07:30:002
540.07100002014-01-03 08:30:000
551.50600002014-01-03 09:00:004
560.07400002014-01-03 10:30:009
572.10800002014-01-03 11:00:004
580.10300002014-01-03 12:00:008
590.48900002014-01-03 19:30:007
600.67200002014-01-03 21:30:007
610.59100002014-01-03 22:00:005
621.93800002014-01-03 22:00:001
630.28400002014-01-03 23:30:004
640.13100002014-01-04 01:00:006
651.54600002014-01-04 01:30:001
660.36100002014-01-04 01:30:006
670.38300002014-01-04 02:00:006
680.18500002014-01-04 02:30:005
690.06200002014-01-04 05:30:008
700.26700002014-01-04 06:00:005
710.07700002014-01-04 06:30:008
720.06800002014-01-04 07:30:002
730.30900002014-01-04 07:30:004
740.15300002014-01-04 10:00:008
750.54500002014-01-04 10:30:007
761.26800002014-01-04 11:30:008
770.07600002014-01-04 12:00:002
781.36000002014-01-04 13:30:008
790.28500002014-01-04 17:00:002
800.44700002014-01-04 17:00:009
810.64100002014-01-04 18:00:004
820.82700002014-01-04 22:30:004
830.32300002014-01-04 23:30:000
840.30500002014-01-05 02:00: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:30:009
890.28100002014-01-05 10:00:003
900.58000002014-01-05 10:00:006
911.13200002014-01-05 11:30:006
920.62500002014-01-05 17:30:004
930.53700002014-01-05 19:30:004
940.54600002014-01-05 19:30:001
950.53900002014-01-05 23:30:009
960.08500002014-01-06 01:00:000
970.08700002014-01-06 02:30:008
980.06900002014-01-06 05:00:003
990.02700002014-01-06 07:30:003
1000.53000002014-01-06 07:30:002
Out[71]:
Rows: 1-100 of 11844 | Columns: 3
In [72]:
sm["time"].slice(length = 30,
                 unit = "minute",
                 start = False)
123
val
Numeric(11,7)
📅
time
Datetime
123
id
Int
10.03700002014-01-01 01:30:002
20.08000002014-01-01 03:00:005
30.08100002014-01-01 03:30:001
41.48900002014-01-01 05:30:003
50.07200002014-01-01 06:30:005
62.30600002014-01-01 07:30:009
70.10200002014-01-01 08:00:004
80.09700002014-01-01 11:00:008
90.02900002014-01-01 11:30:000
100.50600002014-01-01 11:30:006
110.12900002014-01-01 11:30:005
120.62200002014-01-01 13:30:004
130.27700002014-01-01 14:00:000
140.23500002014-01-01 16:00:009
150.62300002014-01-01 17:00:007
161.35000002014-01-01 17:30:005
170.55900002014-01-01 17:30:001
180.37500002014-01-01 19:30:001
190.54000002014-01-01 23:00:009
200.35800002014-01-02 01:00:002
210.13900002014-01-02 02:00:003
220.05500002014-01-02 03:00:003
230.08600002014-01-02 03:30:006
240.04400002014-01-02 04:00:001
250.07300002014-01-02 04:00:008
260.10000002014-01-02 05:00:007
270.04400002014-01-02 06:00:001
280.04800002014-01-02 07:00:001
290.05500002014-01-02 07:00:005
300.08200002014-01-02 10:30:001
310.32100002014-01-02 11:00:000
320.30500002014-01-02 11:30:000
330.39700002014-01-02 13:00:005
340.35800002014-01-02 14:00:000
350.25400002014-01-02 15:00:004
360.11500002014-01-02 16:00:000
370.18500002014-01-02 16:00:007
380.52400002014-01-02 16:30:008
390.87100002014-01-02 18:00:004
401.03800002014-01-02 20:00:009
411.47800002014-01-02 20:00:006
421.77600002014-01-02 20:30:008
430.09400002014-01-03 01:00:008
440.31300002014-01-03 01:00:006
450.13300002014-01-03 02:00:009
460.06000002014-01-03 03:00:006
470.08500002014-01-03 03:30:009
480.06600002014-01-03 05:00:003
490.06800002014-01-03 05:00:001
500.06700002014-01-03 06:00:008
510.03200002014-01-03 07:00:007
520.08400002014-01-03 08:00:009
530.27200002014-01-03 08:00:002
540.07100002014-01-03 09:00:000
551.50600002014-01-03 09:30:004
560.07400002014-01-03 11:00:009
572.10800002014-01-03 11:30:004
580.10300002014-01-03 12:30:008
590.48900002014-01-03 20:00:007
600.67200002014-01-03 22:00:007
610.59100002014-01-03 22:30:005
621.93800002014-01-03 22:30:001
630.28400002014-01-04 00:00:004
640.13100002014-01-04 01:30:006
651.54600002014-01-04 02:00:001
660.36100002014-01-04 02:00:006
670.38300002014-01-04 02:30:006
680.18500002014-01-04 03:00:005
690.06200002014-01-04 06:00:008
700.26700002014-01-04 06:30:005
710.07700002014-01-04 07:00:008
720.06800002014-01-04 08:00:002
730.30900002014-01-04 08:00:004
740.15300002014-01-04 10:30:008
750.54500002014-01-04 11:00:007
761.26800002014-01-04 12:00:008
770.07600002014-01-04 12:30:002
781.36000002014-01-04 14:00:008
790.28500002014-01-04 17:30:002
800.44700002014-01-04 17:30:009
810.64100002014-01-04 18:30:004
820.82700002014-01-04 23:00:004
830.32300002014-01-05 00:00:000
840.30500002014-01-05 02:30:006
850.11100002014-01-05 04:30:009
860.07500002014-01-05 07:00:009
870.09000002014-01-05 08:30:004
880.16000002014-01-05 09:00:009
890.28100002014-01-05 10:30:003
900.58000002014-01-05 10:30:006
911.13200002014-01-05 12:00:006
920.62500002014-01-05 18:00:004
930.53700002014-01-05 20:00:004
940.54600002014-01-05 20:00:001
950.53900002014-01-06 00:00:009
960.08500002014-01-06 01:30:000
970.08700002014-01-06 03:00:008
980.06900002014-01-06 05:30:003
990.02700002014-01-06 08:00:003
1000.53000002014-01-06 08:00:002
Out[72]:
Rows: 1-100 of 11844 | Columns: 3

See Also

vDataFrame[].date_part Extracts a specific TS field from the vcolumn.