---
title: "map(to:)"
framework: createml
role: symbol
role_heading: Instance Method
path: "createml/mluntypedcolumn/map(to:)"
---

# map(to:)

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

## Declaration

```swift
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

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

## Discussion

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