<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateML",
  "identifier" : "/documentation/CreateML/MLDataTable/map(_:)-3yamp",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Create ML"
    ],
    "preciseIdentifier" : "s:8CreateML11MLDataTableV3mapyAA0C6ColumnVyxGxSgAC3RowVcAA0C16ValueConvertibleRzlF"
  },
  "title" : "map(_:)"
}
-->

# map(_:)

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

```
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 `MLDataTable/map(_:)-92wrj` 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`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)