Contents

init(column:)

Creates a new column of machine learning dictionaries from a given column whose elements can be converted to dictionaries.

Declaration

init<T>(column: MLDataColumn<T>) where T : MLDataValueConvertible

Parameters

Discussion

Use this initializer to create a column of dictionaries from another column. Start by creating a column that is convertible to a column of dictionaries.

let intDictionaryString = "{1:\"one\", 2:\"two\", 3:\"three\"}"
let intDictionaryString2 = "{4:\"four\", 5:\"five\", 6:\"six\"}"
let stringsColumn = MLDataColumn([intDictionaryString, intDictionaryString2])

print(stringsColumn) // Prints ["{1:"one", 2:"two", 3:"three"}", "{4:"four", 5:"five", 6:"six"}"]

Then use init(column:) to convert the column to a column of dictionaries.

let dictionaryColumn = MLDataColumn<MLDataValue.DictionaryType>(column: stringsColumn)
print(dictionaryColumn) // Prints [[1: one, 2: two, 3: three], [5: five, 4: four, 6: six]]

See Also

Creating a data column by converting another column