<!--
{
  "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/init(dictionaryLiteral:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "TabularData"
    ],
    "preciseIdentifier" : "s:11TabularData0B5FrameV17dictionaryLiteralACSS_SayypSgGtd_tcfc"
  },
  "title" : "init(dictionaryLiteral:)"
}
-->

# init(dictionaryLiteral:)

Creates a data frame from a dictionary literal.

```
init(dictionaryLiteral elements: (String, [Any?])...)
```

## Parameters

`elements`

A comma-separated, or variadic, list of tuples.
Each tuple consists of two elements:

- A string that represents a column’s name
- An array that represents the elements for that column

## Discussion

Don’t call this initializer directly.
The compiler calls it to create a data frame from a dictionary literal.
You create a dictionary literal by enclosing a comma-separated list of key-value pairs in square brackets.

For example, this line creates a data frame with two columns and four rows:

```swift
let dataFrame: DataFrame = ["a": [1, 2, 3, 5], "b": [1.414, 2.718, 3.14, 6.28]]
```

The initializer checks each column’s elements and, if possible, defines the column’s type to one of the
following:

- `Bool`
- `Int`
- `Float`
- `Double`
- `Date`
- `String`
- `Data`

Otherwise, the data frame sets a column’s type to `Any`.

> Note: Use ``doc://com.apple.TabularData/documentation/TabularData/DataFrame/append(column:)-aema`` to add a column of a specific type.

---

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)