Skip to content

Slice

fast step 

Extract a range/slice of elements from a column of texts or lists.

Using start, stop and step to define a range of indices, the corresponding range of elements is extracted from each text or list in the input column.

Note: indices start at 0, and a stop of 3 means elements up to but not including the element at index 3 will be extracted. In particular this means simply specifying "stop": 3 (setting or leaving start at its default of 0), will extract 3 elements in total.

Usage


The following are the step's expected inputs and outputs and their specific types.

Step signature
slice(input: text|list, {
    "param": value
}) -> (output: column)

where the object {"param": value} is optional in most cases and if present may contain any of the parameters described in the corresponding section below.

Inputs


input: column:text|list

A column containing texts or lists to extract a range of characters or elements from.

Outputs


output: column

Contains the extracted slices. The type depends on the out_type parameter, and needs to be consistent with the transformation.

Parameters


start: integer | null

Index of the first element to be extracted from each string or list in the input column.


stop: integer | null

Index at which to stop including elements from the list. The element at the stop index will not be included. As an example, "start": 0, "stop": 3 will include all elements up to but not including the element at index 3, thus extracting a total of 3 elements.


step: integer | null = 1

Step size used to move from start to stop index. E.g., if "step": 2, only every second element from the range [start, stop] is returned.


out_type: string

Select types using their name.

Must be one of: "category", "date", "number", "boolean", "url", "sex", "text", "list[number]", "list[category]", "list[url]", "list[boolean]", "list[date]"