---
title: MLDataTable
framework: createml
role: symbol
role_heading: Structure
path: createml/mldatatable
---

# MLDataTable

A table of data for training or evaluating a machine learning model.

## Declaration

```swift
struct MLDataTable
```

## Mentioned in

Creating a word tagger model Creating a text classifier model

## Overview

Overview MLDataTable is Create ML’s version of a spreadsheet in which each row represents an entity (such as a book, in the example below) with observable features. Each column (MLDataColumn or MLUntypedColumn) in the table represents an observable feature of that entity, such as a book’s title or author.

In most cases you interact with columns using the typed MLDataColumn, especially when you need to directly access the contents of a column. You can also interact with columns using MLUntypedColumn, if the underlying type of the column isn’t important. After you create a data table, you can modify it with methods like append(contentsOf:), addColumn(_:named:), and removeColumn(named:). You can also filter or map the contents of the data table to derive new data tables or new columns by using various subscripts and methods like dropDuplicates() or map(_:). note: For a demonstration that creates and uses data tables, see Creating a model from tabular data. Finally, when your data table is ready, use it to train and evaluate a model from these groups: Regressors like MLRegressor and its supporting types Classifiers like MLClassifier and its supporting types Natural language processing types like MLTextClassifier and MLWordTagger note: It’s easier to train an MLTextClassifier from folders and files with init(trainingData:parameters:) if your data is ready to use, as-is. Otherwise, use a data table to prepare your data before training a text classifier.

## Topics

### 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(namedColumns:)](createml/mldatatable/init(namedcolumns:).md)
- [init()](createml/mldatatable/init().md)
- [MLDataTable.ParsingOptions](createml/mldatatable/parsingoptions.md)

### Getting the size of a data table

- [size](createml/mldatatable/size.md)

### Transforming rows to generate a data column

- [map(_:)](createml/mldatatable/map(_:).md)

### Adding columns

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

### Accessing columns

- [subscript(_:)](createml/mldatatable/subscript(_:).md)
- [subscript(_:_:)](createml/mldatatable/subscript(_:_:).md)

### Renaming columns

- [renameColumn(named:to:)](createml/mldatatable/renamecolumn(named:to:).md)

### Removing columns

- [removeColumn(named:)](createml/mldatatable/removecolumn(named:).md)

### Appending to a data table

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

### Generating new data tables

- [Data table derivation operations](createml/data-table-derivation-operations.md)

### Splitting a data table

- [randomSplitBySequence(proportion:by:on:seed:)](createml/mldatatable/randomsplitbysequence(proportion:by:on:seed:).md)
- [stratifiedSplit(proportions:on:generator:)](createml/mldatatable/stratifiedsplit(proportions:on:generator:).md)
- [stratifiedSplit(proportions:on:seed:)](createml/mldatatable/stratifiedsplit(proportions:on:seed:).md)
- [stratifiedSplitBySequence(proportions:by:on:generator:)](createml/mldatatable/stratifiedsplitbysequence(proportions:by:on:generator:).md)
- [stratifiedSplitBySequence(proportions:by:on:seed:)](createml/mldatatable/stratifiedsplitbysequence(proportions:by:on:seed:).md)

### Getting information about a data table’s rows

- [MLDataTable.Row](createml/mldatatable/row.md)
- [rows](createml/mldatatable/rows-swift.property.md)
- [MLDataTable.Rows](createml/mldatatable/rows-swift.struct.md)

### Getting information about a data table’s columns

- [columnNames](createml/mldatatable/columnnames-swift.property.md)
- [MLDataTable.ColumnNames](createml/mldatatable/columnnames-swift.struct.md)
- [columnTypes](createml/mldatatable/columntypes.md)

### Saving a data table

- [write(to:)](createml/mldatatable/write(to:).md)
- [write(toDirectory:)](createml/mldatatable/write(todirectory:).md)
- [writeCSV(to:)](createml/mldatatable/writecsv(to:).md)
- [writeCSV(toFile:)](createml/mldatatable/writecsv(tofile:).md)

### Visualizing a data table

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

### Describing a data table

- [description](createml/mldatatable/description.md)
- [playgroundDescription](createml/mldatatable/playgrounddescription.md)

### Handling data table errors

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

### Default Implementations

- [CustomPlaygroundDisplayConvertible Implementations](createml/mldatatable/customplaygrounddisplayconvertible-implementations.md)
- [CustomStringConvertible Implementations](createml/mldatatable/customstringconvertible-implementations.md)

## Relationships

### Conforms To

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

## See Also

### Tabular data

- [MLDataValue](createml/mldatavalue.md)
- [Data visualizations](createml/data-visualizations.md)
