Generic Instance Method

map(_:)

Creates a new column, potentially with missing values, by applying a given thread-safe transform to every row in the data table.

Declaration

func map<T>(_ lazyTransform: @escaping (MLDataTable.Row) -> T?) -> MLDataColumn<T> where T : MLDataValueConvertible

Parameters

lazyTransform

A thread-safe row transformation function.

The implementation of your transform must accept a row from the data table and return an optional type that conforms to MLDataValueConvertible. If the transform returns nil for a given row, the corresponding element in the new column will have a missing value.

Return Value

Discussion

This mapping function is the same as map(_:) with the exception that this version’s lazyTransform parameter returns an optional (T?). Use this version of map() to create empty values by returning nil from your lazyTransform.

See Also

Transforming Rows to Generate a Data Column

func map<T>((MLDataTable.Row) -> T) -> MLDataColumn<T>

Creates a new column by applying a given thread-safe transform to every row in the data table.