<!--
{
  "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/MLUntypedColumn/map(to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Create ML",
      "CreateML"
    ],
    "preciseIdentifier" : "s:8CreateML15MLUntypedColumnV3map2toAA06MLDataD0VyxGxm_tAA0G16ValueConvertibleRzlF"
  },
  "title" : "map(to:)"
}
-->

# map(to:)

Creates a new column of typed values by converting this untyped column
to the given type.

```
func map<T>(to type: T.Type) -> MLDataColumn<T> where T : MLDataValueConvertible
```

## Parameters

`type`

A metatype used to create a new data column of that type.

## Return Value

A new data column if the column’s underlying type is
convertible to given type; otherwise `nil`.

## Discussion

Use this method to convert the elements of the column to a data column
of the given type via [`MLDataValueConvertible`](/documentation/CreateML/MLDataValueConvertible). Unlike
[`column(type:)`](/documentation/CreateML/MLUntypedColumn/column(type:)), which doesn’t alter its elements,
[`map(to:)`](/documentation/CreateML/MLUntypedColumn/map(to:)) converts the elements to the destination
type. For example, you can use [`map(to:)`](/documentation/CreateML/MLUntypedColumn/map(to:)) to convert
an untyped column of integers to a data column of strings.

---

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)