Skip to content

featurebyte.Target.str.slice

slice(
start: Optional[int]=None,
stop: Optional[int]=None,
step: Optional[int]=None
) -> Target

Description

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

  • Target
    A new Target object.

Raises

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

Examples

Slice the first 10 characters from the ProductGroupLookup target:

>>> target = catalog.get_target("ProductGroupLookup")
>>> target["ProductGroupSlice"] = target.str.slice(0, 10)