Skip to content

featurebyte.ViewColumn.str.slice

slice(
start: Union[int, NoneType]=None,
stop: Union[int, NoneType]=None,
step: Union[int, NoneType]=None
) -> FrozenSeries

Description

Slices substring from each string element.

Parameters

  • start: Union[int, NoneType]
    Starting position for slice operation.

  • stop: Union[int, NoneType]
    Ending position for slice operation.

  • step: Union[int, NoneType]
    Step size for slice operation (only size 1 is supported)

Returns

  • FrozenSeries
    A new Column or Feature object.

Raises

  • ValueError
    When the step size is neither None nor 1.

Examples

Slice the first 10 characters from the BrowserUserAgent column:

>>> view = catalog.get_view("GROCERYCUSTOMER")
>>> view["BrowserUserAgentSlice"] = view["BrowserUserAgent"].str.slice(0, 10)
>>> view.preview(5).filter(regex="BrowserUserAgent")
                                    BrowserUserAgent BrowserUserAgentSlice
0  Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.3...            Mozilla/5.
1  Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:6...            Mozilla/5.
2  Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl...            Mozilla/5.
3  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4...            Mozilla/5.
4  Mozilla/5.0 (Windows NT 6.1; Win64; x64) Apple...            Mozilla/5.