<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "TabularData",
  "identifier" : "/documentation/TabularData/DataFrame",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "TabularData"
    ],
    "preciseIdentifier" : "s:11TabularData0B5FrameV"
  },
  "title" : "DataFrame"
}
-->

# DataFrame

A collection that arranges data in rows and columns.

```
@dynamicMemberLookup struct DataFrame
```

## Topics

### Creating a Data Frame

[`init()`](/documentation/TabularData/DataFrame/init())

Creates an empty data frame with no rows or columns.

[`init(columns:)`](/documentation/TabularData/DataFrame/init(columns:))

Creates a new data frame from a sequence of columns.

[`init(dictionaryLiteral:)`](/documentation/TabularData/DataFrame/init(dictionaryLiteral:))

Creates a data frame from a dictionary literal.

### Creating a Data Frame from Other Data Frames

[`init(_:)`](/documentation/TabularData/DataFrame/init(_:))

Creates a new data frame with a slice of rows from another data frame.

[`DataFrame.Slice`](/documentation/TabularData/DataFrame/Slice)

A set of a data frame’s rows you create by using a method from a data frame instance
or another data frame slice.

  <doc:API-Data-Frame-Generating-Methods--DataFrame>

### Creating a Data Frame from a JSON File

[`init(contentsOfJSONFile:columns:types:options:)`](/documentation/TabularData/DataFrame/init(contentsOfJSONFile:columns:types:options:))

Creates a data frame by reading a JSON file.

[`init(jsonData:columns:types:options:)`](/documentation/TabularData/DataFrame/init(jsonData:columns:types:options:))

Creates a data frame by converting JSON data.

[`JSONType`](/documentation/TabularData/JSONType)

Represents the value types in a JSON file.

[`JSONReadingOptions`](/documentation/TabularData/JSONReadingOptions)

A set of JSON file-reading options.

### Creating a Data Frame from a CSV

[`init(contentsOfCSVFile:columns:rows:types:options:)`](/documentation/TabularData/DataFrame/init(contentsOfCSVFile:columns:rows:types:options:))

Creates a data frame from a CSV file.

[`init(csvData:columns:rows:types:options:)`](/documentation/TabularData/DataFrame/init(csvData:columns:rows:types:options:))

Creates a data frame from CSV data.

[`CSVType`](/documentation/TabularData/CSVType)

Represents the value types in a CSV file.

[`CSVReadingOptions`](/documentation/TabularData/CSVReadingOptions)

A set of CSV file-reading options.

### Creating a Data Frame from Turi Create Types

[`init(contentsOfSFrameDirectory:columns:rows:)`](/documentation/TabularData/DataFrame/init(contentsOfSFrameDirectory:columns:rows:))

Creates a data frame from a Turi Create scalable data frame.

[`ShapedData`](/documentation/TabularData/ShapedData)

A collection type that represents multidimensional data in a data frame element.

### Inspecting a Data Frame

[`shape`](/documentation/TabularData/DataFrame/shape)

The number of rows and columns in the data frame.

[`columns`](/documentation/TabularData/DataFrame/columns)

The entire data frame as a collection of columns.

[`rows`](/documentation/TabularData/DataFrame/rows-swift.property)

The entire data frame as a collection of rows.

[`DataFrame.Rows`](/documentation/TabularData/DataFrame/Rows-swift.struct)

A collection of rows in a data frame.

[`base`](/documentation/TabularData/DataFrame/base)

The underlying data frame.

[`containsColumn(_:_:)`](/documentation/TabularData/DataFrame/containsColumn(_:_:))

Returns a Boolean value indicating whether the data frame contains a column.

### Working with Rows and Columns

  <doc:API-Row-Operations--DataFrame>

  <doc:API-Column-Operations--DataFrame>

### Sorting a Data Frame

[`sort(on:order:)`](/documentation/TabularData/DataFrame/sort(on:order:)-4vns7)

Arranges the rows of a data frame according to a column that you select by its name.

[`sort(on:_:order:)`](/documentation/TabularData/DataFrame/sort(on:_:order:)-78avw)

Arranges the rows of a data frame according to a column that you select by its name and type.

[`sort(on:_:by:)`](/documentation/TabularData/DataFrame/sort(on:_:by:))

Arranges the rows of a data frame according to a column that you select by its name and type,
with a predicate.

[`sort(on:by:)`](/documentation/TabularData/DataFrame/sort(on:by:))

Arranges the rows of a data frame according to a column that you select by its column identifier,
with a predicate.

[`sort(on:order:)`](/documentation/TabularData/DataFrame/sort(on:order:)-5ep7w)

Arranges the rows of a data frame according to a column that you select by its column identifier.

[`sort(on:_:order:)`](/documentation/TabularData/DataFrame/sort(on:_:order:)-8wrkl)

Arranges the rows of a data frame according to two columns that you select by their column identifiers.

[`sort(on:_:_:order:)`](/documentation/TabularData/DataFrame/sort(on:_:_:order:))

Arranges the rows of a data frame according to three columns that you select by their column identifiers.

### Summarizing a Data Frame

[`summary()`](/documentation/TabularData/DataFrame/summary())

Generates a data frame that summarizes the columns of the data frame.

[`summary(of:)`](/documentation/TabularData/DataFrame/summary(of:))

Generates a data frame that summarizes the columns you select by name.

[`summary(ofColumns:)`](/documentation/TabularData/DataFrame/summary(ofColumns:))

Generates a data frame that summarizes the columns you select by index.

[`SummaryColumnIDs`](/documentation/TabularData/SummaryColumnIDs)

The summary data frame column identifiers.

### Saving a Data Frame to a CSV Format

[`CSVWritingOptions`](/documentation/TabularData/CSVWritingOptions)

A set of CSV file-writing options.

### Describing a Data Frame

[`description`](/documentation/TabularData/DataFrame/description)

A text representation of the data frame.

[`debugDescription`](/documentation/TabularData/DataFrame/debugDescription)

A text representation of the data frame suitable for debugging.

[`customMirror`](/documentation/TabularData/DataFrame/customMirror)

A mirror that reflects the data frame.

### Comparing Data Frames

[`==(_:_:)`](/documentation/TabularData/DataFrame/==(_:_:))

Returns a Boolean that indicates whether the data frames are equal.

### Hashing a Data Frame

[`hash(into:)`](/documentation/TabularData/DataFrame/hash(into:))

Hashes the essential components of the data frame by feeding them into a hasher.



---

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)