Contents

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

A new MLDataColumn.

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.