Contents

init(column:)

Creates a new column of arrays of strings from a given column whose elements can be converted to an array of strings.

Declaration

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

Parameters

Discussion

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

let stringArrayString = "[\"Array\", \"of\", \"strings\", \"1\"]"
let stringArrayString2 = "[\"Array\", \"of\", \"strings\", \"2\"]"
let stringsColumn = MLDataColumn([stringArrayString, stringArrayString2])

print(stringsColumn) // Prints ["["Array", "of", "strings", "1"]", "["Array", "of", "strings", "2"]"]

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

let stringArrayColumn = MLDataColumn<[String]>(column: stringsColumn)
print(stringArrayColumn) // Prints [["Array", "of", "strings", "1"], ["Array", "of", "strings", "2"]]

See Also

Creating a data column by converting another column