<!--
{
  "documentType" : "article",
  "framework" : "CreateML",
  "identifier" : "/documentation/CreateML/data-table-derivation-operations",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Data table derivation operations"
}
-->

# Data table derivation operations

Create new data tables by manipulating an existing data table.

## Overview

Use these methods to preprocess your data programmatically in Create ML before training
a model. For example, you can create a data table by merging two data tables, fill
in missing values, and then discarding duplicate rows.

All of these methods create new data tables, leaving the original data table unmodified.

## Topics

### Aggregating rows

[`func group<S>(columnsNamed: String..., aggregators: S) -> MLDataTable`](/documentation/CreateML/MLDataTable/group(columnsNamed:aggregators:))

Creates a new data table with the given columns and adds a new column
for each of the given aggregators.

[`struct Aggregator`](/documentation/CreateML/MLDataTable/Aggregator)

A collection of column operations you can use with a data table’s
`group` method.

### Sorting rows

[`func sort(columnNamed: String, byIncreasingOrder: Bool) -> MLDataTable`](/documentation/CreateML/MLDataTable/sort(columnNamed:byIncreasingOrder:))

Creates a new data table by sorting the table by the given column.

### Splitting a data table

[`func randomSplit(by: Double, seed: Int) -> (MLDataTable, MLDataTable)`](/documentation/CreateML/MLDataTable/randomSplit(by:seed:))

Creates two mutually exclusive, randomly divided subsets of the table.

### Merging data tables

[`func join(with: MLDataTable, on: String..., type: MLDataTable.JoinType) -> MLDataTable`](/documentation/CreateML/MLDataTable/join(with:on:type:))

Creates a new data table by merging two data tables by the given
columns.

[`enum JoinType`](/documentation/CreateML/MLDataTable/JoinType)

Join types available for [`MLDataTable`](/documentation/CreateML/MLDataTable) join operations.

### Filling in missing values

[`func fillMissing(columnNamed: String, with: MLDataValue) -> MLDataTable`](/documentation/CreateML/MLDataTable/fillMissing(columnNamed:with:))

Creates a modified copy of the table by filling in the missing values in
the named column.

### Masking rows

[`subscript(MLDataColumn<Bool>) -> MLDataTable`](/documentation/CreateML/MLDataTable/subscript(_:)-3opgl)

Creates a subset of the table by masking the rows with the given column
of Booleans.

[`subscript(MLUntypedColumn) -> MLDataTable`](/documentation/CreateML/MLDataTable/subscript(_:)-10r4l)

Creates a subset of the table by masking the rows with the given untyped
column.

### Discarding rows

[`func dropMissing() -> MLDataTable`](/documentation/CreateML/MLDataTable/dropMissing())

Creates a subset of the table by removing any row missing one or more
values.

[`func dropDuplicates() -> MLDataTable`](/documentation/CreateML/MLDataTable/dropDuplicates())

Creates a subset of the table by removing all duplicate rows.

[`func exclude<T>(T..., of: String) -> MLDataTable`](/documentation/CreateML/MLDataTable/exclude(_:of:))

Creates a subset of the table by excluding the rows that contain any of
the given values in the given column.

[`func randomSample(by: Double, seed: Int) -> MLDataTable`](/documentation/CreateML/MLDataTable/randomSample(by:seed:))

Creates a subset of the table by randomly selecting the given proportion
of rows.

### Selecting rows

[`subscript(Range<Int>) -> MLDataTable`](/documentation/CreateML/MLDataTable/subscript(_:)-7h4j3)

Creates a subset of the table given a range of rows.

[`subscript<R>(R) -> MLDataTable`](/documentation/CreateML/MLDataTable/subscript(_:)-5le8a)

Creates a subset of the table given a range expression of rows.

[`func prefix(Int) -> MLDataTable`](/documentation/CreateML/MLDataTable/prefix(_:))

Creates a subset of the table given a number of initial rows.

[`func suffix(Int) -> MLDataTable`](/documentation/CreateML/MLDataTable/suffix(_:))

Creates a subset of the table given a number of final rows.

[`func intersect<T>(T..., of: String) -> MLDataTable`](/documentation/CreateML/MLDataTable/intersect(_:of:))

Creates a subset of the table by including the rows that contain any of
the given values in the given column.

### Selecting columns

[`subscript<S>(S) -> MLDataTable`](/documentation/CreateML/MLDataTable/subscript(_:)-2wkan)

Creates a subset of the table given a sequence of column names.

### Compacting rows

[`func condense(columnNamed: String, to: String) -> MLDataTable`](/documentation/CreateML/MLDataTable/condense(columnNamed:to:))

Creates a new data table where duplicate row values in the given column
are condensed into a new sequence-type column.

### Expanding rows

[`func expand(columnNamed: String, to: String) -> MLDataTable`](/documentation/CreateML/MLDataTable/expand(columnNamed:to:))

Creates a new data table where duplicate row values in the given column
are condensed into a new sequence-type column.

### Compacting columns

[`func pack(columnsNamed: String..., to: String, type: MLDataTable.PackType, filling: MLDataValue) -> MLDataTable`](/documentation/CreateML/MLDataTable/pack(columnsNamed:to:type:filling:))

Creates a new data table with an additional column that contains the
combined values of the given columns.

[`enum PackType`](/documentation/CreateML/MLDataTable/PackType)

The storage operations for combining multiple columns into one.

### Expanding columns

[`func unpack(columnNamed: String, valueTypes: [MLDataValue.ValueType]?, indexSubset: [Int]?, keySubset: [String]?) -> MLDataTable`](/documentation/CreateML/MLDataTable/unpack(columnNamed:valueTypes:indexSubset:keySubset:))

Creates a new data table with additional columns that contain the
unpacked collections in the given column.



---

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)