---
title: MLUntypedColumn
framework: createml
role: symbol
role_heading: Structure
path: createml/mluntypedcolumn
---

# MLUntypedColumn

A column of untyped values in a data table.

## Declaration

```swift
struct MLUntypedColumn
```

## Overview

Overview A column is a homogenous collection of data values, similar to an Array. Columns are the main components of an MLDataTable and are designed to efficiently scale with large data sets. Typically you use MLDataColumn, the typed equivalent to MLUntypedColumn, for its type-specific functionality. Untyped columns are especially useful when: You’re initializing a data table with columns by using init(namedColumns:). You’re using columns of a non-Boolean type to filter a data table with subscript(_:). You don’t need to work directly with the underlying type. Each element of an untyped column is an MLDataValue, and has an underlying type that conforms to MLDataValueConvertible. The underlying type is hidden from the Swift compiler and is what makes an MLUntypedColumn untyped. Using an untyped column allows you to quickly write type-agnostic code with Create ML. let column = MLUntypedColumn([2, 3, 5, 7, 11]) let columnOver2 = column / 2 print(columnOver2) /* Prints...  ValueType: Double  Values:        [1.0, 1.5, 2.5, 3.5, 5.5]  */ However, by avoiding type safety at compile time, you expose your code to errors at runtime. When an error occurs during an operation, Create ML marks the product of that operation invalid by setting isValid to false and by setting error with a value. For example, using a slash (/) operator to divide a column of integers with a string produces an invalid column. let column = MLUntypedColumn([2, 3, 5, 7, 11]) let invalidColumn = column / "foo" print(invalidColumn.isValid) // Prints "false" important: A mismatch between the underlying types of two columns, or between the underlying type of a column and the type of a value, will result in an invalid column. Once a column becomes invalid, you can’t use it for any subsequent operation because it will only produce further invalid columns or invalid tables. Each comparison operator of MLUntypedColumn returns a column of Booleans. However, MLUntypedColumn uses integers as its underlying type for columns of Booleans, because MLDataValue does not have a case for Bool. For example, create an untyped column of Booleans using the less-than comparison operator(<(_:_:)). let column = MLUntypedColumn([2, 3, 5, 7, 11]) let lessThan5 = column < 5 Then print the column to see that its underlying ValueType is Int, and each Boolean value of true or false is represented in the column by an integer value of 1 or 0, respectively. print(lessThan5) /* Prints...  ValueType: Int  Values:        [1, 1, 0, 0, 0]  */ Use these untyped columns of Booleans just as you would with a typed column of Booleans (``MLDataColumn```<<doc://com.apple.documentation/documentation/swift/bool>>`) to: Filter another untyped column with subscript(_:) Logically combine with another untyped column of Booleans with the &&(_:_:) and ||(_:_:) operators Mask rows of an MLDataTable with its subscript(_:)

## Topics

### Creating an untyped column

- [init(repeating:count:)](createml/mluntypedcolumn/init(repeating:count:).md)
- [init(repeating:count:)](createml/mluntypedcolumn/init(repeating:count:)-7ttf1.md)
- [init(repeating:count:)](createml/mluntypedcolumn/init(repeating:count:)-q8yk.md)
- [init(_:)](createml/mluntypedcolumn/init(_:).md)
- [init(_:)](createml/mluntypedcolumn/init(_:)-33tcv.md)
- [init(_:)](createml/mluntypedcolumn/init(_:)-9no5.md)
- [init(_:)](createml/mluntypedcolumn/init(_:)-ag8f.md)
- [init(_:)](createml/mluntypedcolumn/init(_:)-5by2g.md)
- [init()](createml/mluntypedcolumn/init().md)

### Creating an untyped column by converting another column

- [init(ints:)](createml/mluntypedcolumn/init(ints:).md)
- [init(doubles:)](createml/mluntypedcolumn/init(doubles:).md)
- [init(strings:)](createml/mluntypedcolumn/init(strings:).md)
- [init(sequences:)](createml/mluntypedcolumn/init(sequences:).md)
- [init(dictionaries:)](createml/mluntypedcolumn/init(dictionaries:).md)
- [init(multiArrays:)](createml/mluntypedcolumn/init(multiarrays:).md)

### Getting the number of elements

- [count](createml/mluntypedcolumn/count.md)
- [isEmpty](createml/mluntypedcolumn/isempty.md)

### Getting an element

- [subscript(_:)](createml/mluntypedcolumn/subscript(_:)-6j6rb.md)

### Appending to an untyped column

- [append(contentsOf:)](createml/mluntypedcolumn/append(contentsof:).md)

### Duplicating a column

- [copy()](createml/mluntypedcolumn/copy().md)

### Sorting elements to generate a column

- [sort(byIncreasingOrder:)](createml/mluntypedcolumn/sort(byincreasingorder:).md)

### Converting a column to generate a data column

- [map(to:)](createml/mluntypedcolumn/map(to:).md)

### Exposing the underlying type to generate a data column

- [type](createml/mluntypedcolumn/type.md)
- [ints](createml/mluntypedcolumn/ints.md)
- [doubles](createml/mluntypedcolumn/doubles.md)
- [strings](createml/mluntypedcolumn/strings.md)
- [sequences](createml/mluntypedcolumn/sequences.md)
- [dictionaries](createml/mluntypedcolumn/dictionaries.md)
- [multiArrays](createml/mluntypedcolumn/multiarrays.md)
- [column(type:)](createml/mluntypedcolumn/column(type:).md)

### Transforming elements to generate a data column

- [map(_:)](createml/mluntypedcolumn/map(_:).md)
- [map(_:)](createml/mluntypedcolumn/map(_:)-139qy.md)
- [map(_:)](createml/mluntypedcolumn/map(_:)-9v61j.md)
- [mapMissing(_:)](createml/mluntypedcolumn/mapmissing(_:).md)

### Masking elements to generate an untyped column

- [subscript(_:)](createml/mluntypedcolumn/subscript(_:).md)
- [subscript(_:)](createml/mluntypedcolumn/subscript(_:)-8ot43.md)
- [subscript(_:)](createml/mluntypedcolumn/subscript(_:)-9hr32.md)

### Discarding elements to generate an untyped column

- [dropMissing()](createml/mluntypedcolumn/dropmissing().md)
- [dropDuplicates()](createml/mluntypedcolumn/dropduplicates().md)

### Selecting elements to generate an untyped column

- [subscript(_:)](createml/mluntypedcolumn/subscript(_:)-33ua2.md)
- [subscript(_:)](createml/mluntypedcolumn/subscript(_:)-9dpy7.md)
- [prefix(_:)](createml/mluntypedcolumn/prefix(_:).md)
- [suffix(_:)](createml/mluntypedcolumn/suffix(_:).md)

### Filling in missing elements to generate an untyped column

- [fillMissing(with:)](createml/mluntypedcolumn/fillmissing(with:).md)

### Evaluating elements to generate an untyped column

- [materialize()](createml/mluntypedcolumn/materialize().md)

### Combining columns

- [+(_:_:)](createml/mluntypedcolumn/+(_:_:).md)
- [-(_:_:)](createml/mluntypedcolumn/-(_:_:).md)
- [*(_:_:)](createml/mluntypedcolumn/*(_:_:).md)
- [/(_:_:)](createml/mluntypedcolumn/_(_:_:)-20v6v.md)

### Combining columns to generate an untyped column

- [+(_:_:)](createml/mluntypedcolumn/+(_:_:)-bcc5.md)
- [-(_:_:)](createml/mluntypedcolumn/-(_:_:)-3h4o4.md)
- [*(_:_:)](createml/mluntypedcolumn/*(_:_:)-2p6nm.md)
- [/(_:_:)](createml/mluntypedcolumn/_(_:_:)-45tpp.md)

### Combining a column with a value to generate an untyped column

- [+(_:_:)](createml/mluntypedcolumn/+(_:_:)-4vnbk.md)
- [-(_:_:)](createml/mluntypedcolumn/-(_:_:)-4uigi.md)
- [*(_:_:)](createml/mluntypedcolumn/*(_:_:)-6gnlx.md)
- [/(_:_:)](createml/mluntypedcolumn/_(_:_:)-18srk.md)

### Combining a value with a column to generate an untyped column

- [+(_:_:)](createml/mluntypedcolumn/+(_:_:)-miqp.md)
- [-(_:_:)](createml/mluntypedcolumn/-(_:_:)-9gm9i.md)
- [*(_:_:)](createml/mluntypedcolumn/*(_:_:)-7svdc.md)
- [/(_:_:)](createml/mluntypedcolumn/_(_:_:)-aw9o.md)

### Comparing columns

- [==(_:_:)](createml/mluntypedcolumn/==(_:_:).md)
- [!=(_:_:)](createml/mluntypedcolumn/!=(_:_:).md)
- [>(_:_:)](createml/mluntypedcolumn/_(_:_:)-1hr3j.md)
- [<(_:_:)](createml/mluntypedcolumn/_(_:_:)-9ke05.md)
- [<=(_:_:)](createml/mluntypedcolumn/_=(_:_:)-2i3xz.md)
- [>=(_:_:)](createml/mluntypedcolumn/_=(_:_:)-221lt.md)

### Comparing columns to generate an untyped column of booleans

- [==(_:_:)](createml/mluntypedcolumn/==(_:_:)-3o7mo.md)
- [!=(_:_:)](createml/mluntypedcolumn/!=(_:_:)-86hu4.md)
- [>(_:_:)](createml/mluntypedcolumn/_(_:_:)-9r2zq.md)
- [<(_:_:)](createml/mluntypedcolumn/_(_:_:)-7zms0.md)
- [<=(_:_:)](createml/mluntypedcolumn/_=(_:_:)-5xmwz.md)
- [>=(_:_:)](createml/mluntypedcolumn/_=(_:_:)-4u3ir.md)

### Comparing a column with a value to generate an untyped column of booleans

- [==(_:_:)](createml/mluntypedcolumn/==(_:_:)-7xysh.md)
- [!=(_:_:)](createml/mluntypedcolumn/!=(_:_:)-7do9.md)
- [>(_:_:)](createml/mluntypedcolumn/_(_:_:)-2mdrt.md)
- [<(_:_:)](createml/mluntypedcolumn/_(_:_:)-8w60f.md)
- [<=(_:_:)](createml/mluntypedcolumn/_=(_:_:)-1wkt3.md)
- [>=(_:_:)](createml/mluntypedcolumn/_=(_:_:)-2vu3g.md)

### Comparing a value with a column to generate an untyped column of booleans

- [==(_:_:)](createml/mluntypedcolumn/==(_:_:)-6z88q.md)
- [!=(_:_:)](createml/mluntypedcolumn/!=(_:_:)-6k3p6.md)
- [>(_:_:)](createml/mluntypedcolumn/_(_:_:)-52drj.md)
- [<(_:_:)](createml/mluntypedcolumn/_(_:_:)-6qou9.md)
- [<=(_:_:)](createml/mluntypedcolumn/_=(_:_:)-t4bt.md)
- [>=(_:_:)](createml/mluntypedcolumn/_=(_:_:)-6yycf.md)

### Combining columns of booleans to generate an untyped column of booleans

- [&&(_:_:)](createml/mluntypedcolumn/&&(_:_:).md)
- [||(_:_:)](createml/mluntypedcolumn/__(_:_:).md)

### Visualizing a column

- [show()](createml/mluntypedcolumn/show().md)

### Getting a description of an untyped column

- [description](createml/mluntypedcolumn/description.md)
- [playgroundDescription](createml/mluntypedcolumn/playgrounddescription.md)
- [debugDescription](createml/mluntypedcolumn/debugdescription.md)
- [customMirror](createml/mluntypedcolumn/custommirror.md)

### Handling untyped column errors

- [isValid](createml/mluntypedcolumn/isvalid.md)
- [error](createml/mluntypedcolumn/error.md)

### Default Implementations

- [CustomDebugStringConvertible Implementations](createml/mluntypedcolumn/customdebugstringconvertible-implementations.md)
- [CustomPlaygroundDisplayConvertible Implementations](createml/mluntypedcolumn/customplaygrounddisplayconvertible-implementations.md)
- [CustomReflectable Implementations](createml/mluntypedcolumn/customreflectable-implementations.md)
- [CustomStringConvertible Implementations](createml/mluntypedcolumn/customstringconvertible-implementations.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomPlaygroundDisplayConvertible](swift/customplaygrounddisplayconvertible.md)
- [CustomReflectable](swift/customreflectable.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Escapable](swift/escapable.md)

## See Also

### Adding columns

- [addColumn(_:named:)](createml/mldatatable/addcolumn(_:named:).md)
- [MLDataColumn](createml/mldatacolumn.md)
