---
title: "init(namedColumns:)"
framework: createml
role: symbol
role_heading: Initializer
path: "createml/mldatatable/init(namedcolumns:)"
---

# init(namedColumns:)

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

## Declaration

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

## Parameters

- `namedColumns`: The dictionary of each column name and its associated untyped column data.

## Discussion

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

For example, to create a data table as shown above, first create your untyped columns. 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:) to create a data table from the columns paired with their names. let bookTable = try MLDataTable(namedColumns: ["Title": title,                                                "Author": author,                                                "Pages": pages,                                                "Genre": genre])

## See Also

### Creating a data table

- [Creating a model from tabular data](createml/creating-a-model-from-tabular-data.md)
- [init(contentsOf:options:)](createml/mldatatable/init(contentsof:options:).md)
- [init(dictionary:)](createml/mldatatable/init(dictionary:).md)
- [init()](createml/mldatatable/init().md)
- [MLDataTable.ParsingOptions](createml/mldatatable/parsingoptions.md)
