Contents

init(doubles:)

Creates a new column of doubles by converting the elements of another column.

Declaration

init(doubles: MLUntypedColumn)

Parameters

  • doubles:

    A column with elements that are convertible to doubles.

Return Value

A new untyped column of doubles; otherwise an invalid column if any element of the given column cannot be converted to Double.

Discussion

Use this initializer to create a column of doubles from another column. As an example, to create a column with this initializer, first start with a column that is convertible to doubles.

let stringColumn = MLUntypedColumn(["1.0", "2.0", "3.0", "4.0", "5.0"])
print(stringColumn)
/* Prints...
 ValueType: String
 Values:        [1.0, 2.0, 3.0, 4.0, 5.0]
 */

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

let doublesColumn = MLUntypedColumn(doubles: stringColumn)
print(doublesColumn)
/* Prints...
 ValueType: Double
 Values:        [1.0, 2.0, 3.0, 4.0, 5.0]
 */

See Also

Creating an untyped column by converting another column