[//]: # (title: Create DataColumn) This section describes ways to create a [`DataColumn`](DataColumn.md). ### columnOf Returns new column with the given elements. The column [`type`](DataColumn.md#properties) is deduced from the compile-time type of the elements inside. The column [`name`](DataColumn.md#properties) is taken from the name of the variable. ```kotlin // Create ValueColumn with name 'student' and two elements of type String val student by columnOf("Alice", "Bob") ``` To assign column name explicitly, use the `named` infix function and replace `by` with `=`. ```kotlin val column = columnOf("Alice", "Bob") named "student" ``` When column elements are columns themselves, it returns a [`ColumnGroup`](DataColumn.md#columngroup): ```kotlin val firstName by columnOf("Alice", "Bob") val lastName by columnOf("Cooper", "Marley") // Create ColumnGroup with two nested columns val fullName by columnOf(firstName, lastName) ``` When column elements are [`DataFrame`](DataFrame.md) objects it returns a [`FrameColumn`](DataColumn.md#framecolumn): ```kotlin val df1 = dataFrameOf("name", "age")("Alice", 20, "Bob", 25) val df2 = dataFrameOf("name", "temp")("Charlie", 36.6) // Create FrameColumn with two elements of type DataFrame val frames by columnOf(df1, df2) ``` ### toColumn Converts an `Iterable` of values into a column. ```kotlin listOf("Alice", "Bob").toColumn("name") ``` To compute a column type at runtime by scanning through the actual values, enable the `Infer.Type` option. To inspect values only for nullability, enable the `Infer.Nulls` option. ```kotlin val values: List = listOf(1, 2.5) values.toColumn("data") // type: Any? values.toColumn("data", Infer.Type) // type: Number values.toColumn("data", Infer.Nulls) // type: Any ``` ### toColumnOf Converts an [`Iterable`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/) of values into a column of a given type: ```kotlin val values: List = listOf(1, 2.5) values.toColumnOf("data") // type: Number? ```