featurebyte.ViewColumn.str.slice¶
slice(
start: Optional[int]=None,
stop: Optional[int]=None,
step: Optional[int]=None
) -> FrozenSeriesDescription¶
Slices substring from each string element.
Parameters¶
- start: Optional[int]
Starting position for slice operation. - stop: Optional[int]
Ending position for slice operation. - step: Optional[int]
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.