init(dictionaryLiteral:)
Creates a data frame from a dictionary literal.
Declaration
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:
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:
BoolIntFloatDoubleDateStringData
Otherwise, the data frame sets a column’s type to Any.