<!--
{
  "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/init(namedColumns:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Create ML"
    ],
    "preciseIdentifier" : "s:8CreateML11MLDataTableV12namedColumnsACSDySSAA15MLUntypedColumnVG_tKcfc"
  },
  "title" : "init(namedColumns:)"
}
-->

# init(namedColumns:)

Creates a data table from a dictionary of column names and untyped
columns.

```
init(namedColumns: [String : MLUntypedColumn]) throws
```

## Parameters

`namedColumns`

The dictionary of each column name and its associated untyped column data.

## Discussion

Use this initializer to create a data table from untyped columns.

![A table of information about a book. Columns named “Title”, “Author”,](images/com.apple.createml/MLDataTable-init(namedColumns:)-1@2x.png)

For example, to create a data table as shown above, first create your
untyped columns.

```swift
let pages = MLUntypedColumn([124, 98, 280, 94])
let genre = MLUntypedColumn(["Fantasy", "Drama", "Adventure", "Fantasy"])
let title = MLUntypedColumn(["Alice in Wonderland", "Hamlet", "Treasure Island", "Peter Pan"])
let author = MLUntypedColumn(["Lewis Carroll", "William Shakespeare", "Robert L. Stevenson", "J. M. Barrie"])
```

Then, use [`init(namedColumns:)`](/documentation/CreateML/MLDataTable/init(namedColumns:)) to create a data table
from the columns paired with their names.

```swift
let bookTable = try MLDataTable(namedColumns: ["Title": title,
                                               "Author": author,
                                               "Pages": pages,
                                               "Genre": genre])
```

---

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)