---
title: "addColumn(_:named:)"
framework: createml
role: symbol
role_heading: Instance Method
path: "createml/mldatatable/addcolumn(_:named:)-9cb24"
---

# addColumn(_:named:)

Adds an untyped column to the table.

## Declaration

```swift
mutating func addColumn(_ newColumn: MLUntypedColumn, named: String)
```

## Parameters

- `newColumn`: A column to add to the data table.
- `named`: The name of the new column.

## Discussion

Discussion Use this method to add an untyped column to a data table. important: The number of elements in the column must equal the number of rows in the data table. Otherwise, the data table will be invalidated. As an example, start with a data table variable. let data: [String: MLDataValueConvertible] = [     "Title": ["Alice in Wonderland", "Hamlet", "Treasure Island", "Peter Pan"],     "Author": ["Lewis Carroll", "William Shakespeare", "Robert L. Stevenson", "J. M. Barrie"],     "Pages": [124, 98, 280, 94], ]

var bookTable = try MLDataTable(dictionary: data) Then use addColumn(_:named:) to add a column to the table. let pagesColumn = MLUntypedColumn([124, 98, 280, 94]) bookTable.addColumn(pagesColumn, named: "Pages")
