datatable.str.slice()

Apply slice [start:stop:step] to each value in a column of string type.

Instead of this function you can directly apply a slice expression to the column expression:

- ``f.A[1:-1]`` is equivalent to - ``dt.str.slice(f.A, 1, -1)``.

Parameters

col
FExpr[str]

The column to which the slice should be applied.

return
FExpr[str]

A column containing sliced string values from the source column.

Examples

DT = dt.Frame(A=["apples", "bananas", "cherries", "dates", "eggplants", "figs", "grapes", "kiwi"]) DT[:, dt.str.slice(f.A, None, 5)]
A
str32
0apple
1banan
2cherr
3dates
4eggpl
5figs
6grape
7kiwi