@@ -132,13 +132,18 @@ public interface DataColumn<out T> : BaseColumn<T> {
132
132
/* *
133
133
* Creates either a [FrameColumn], [ColumnGroup], or [ValueColumn] by analyzing each value in
134
134
* [values].
135
+ *
135
136
* This is safer but less efficient than the other functions.
136
137
*
137
- * Some conversions are done automatically to attempt to unify the values, like:
138
- * - `null` -> [DataFrame.empty][DataFrame.empty]`()` and [DataRow] -> single-row [DataFrame] when there are other
139
- * [DataFrames][DataFrame] present in [values]
140
- * - [List][List]`<`[DataRow][DataRow]`<*>>` -> [DataFrame]
141
- * etc.
138
+ * Some conversions are done automatically to attempt to unify the values.
139
+ *
140
+ * For instance, when there are other [DataFrames][DataFrame] present in [values], we'll convert:
141
+ * - `null` -> [DataFrame.empty]`()`
142
+ * - [DataRow] -> single-row [DataFrame]
143
+ * - [List][List]`<`[DataRow][DataRow]`<*>>` -> multi-row [DataFrame]
144
+ *
145
+ * to be able to create a [FrameColumn].
146
+ * There are more conversions for other types as well.
142
147
*
143
148
* @param name name of the column
144
149
* @param values the values to represent each row in the column
@@ -163,12 +168,12 @@ public interface DataColumn<out T> : BaseColumn<T> {
163
168
* Calls [createColumnGroup], [createFrameColumn], or [createValueColumn] based on
164
169
* [type].
165
170
*
171
+ * This may be unsafe but is more efficient than [createWithTypeInference].
172
+ *
166
173
* Be careful; Values in [values] are NOT checked to adhere to the given [type], nor
167
- * do we check whether there are nulls among the values when the given type is [DataFrame]
168
- * (a [FrameColumn] cannot contain `null`, this causes runtime exceptions).
169
- * When [type] is `DataFrame<*>?`, a [ValueColumn] is created to avoid this issue.
174
+ * do we check whether there are unexpected nulls among the values.
170
175
*
171
- * This may be unsafe but is more efficient than [createWithTypeInference] .
176
+ * It's recommended to use [createValueColumn], [createColumnGroup], and [createFrameColumn] instead .
172
177
*
173
178
* @param name the name of the column
174
179
* @param values the values to represent each row in the column
@@ -181,22 +186,24 @@ public interface DataColumn<out T> : BaseColumn<T> {
181
186
type : KType ,
182
187
infer : Infer = Infer .None ,
183
188
): DataColumn <T > =
184
- when (type.toColumnKind()) {
189
+ when (type.toColumnKind()) { // AnyFrame -> Frame, AnyRow? -> Group, else -> Value
185
190
ColumnKind .Value -> createValueColumn(name, values, type, infer)
191
+
186
192
ColumnKind .Group -> createColumnGroup(name, (values as List <AnyRow ?>).concat()).asDataColumn().cast()
193
+
187
194
ColumnKind .Frame -> createFrameColumn(name, values as List <AnyFrame >).asDataColumn().cast()
188
195
}
189
196
190
197
/* *
191
198
* Calls [createColumnGroup], [createFrameColumn], or [createValueColumn] based on
192
199
* type [T].
193
200
*
194
- * Be careful; Values in [values] are NOT checked to adhere to the given [type], nor
195
- * do we check whether there are nulls among the values when the given type is [DataFrame]
196
- * (a [FrameColumn] cannot contain `null`, this causes runtime exceptions).
197
- * When [type] is `DataFrame<*>?`, a [ValueColumn] is created to avoid this issue.
201
+ * This is generally safe, as [T] can be inferred, and more efficient than [createWithTypeInference].
198
202
*
199
- * This may be unsafe but is more efficient than [createWithTypeInference].
203
+ * Be careful when casting occurs; Values in [values] are NOT checked to adhere to the given/inferred type [T],
204
+ * nor do we check whether there are unexpected nulls among the values.
205
+ *
206
+ * It's recommended to use [createValueColumn], [createColumnGroup], and [createFrameColumn] instead.
200
207
*
201
208
* @param T the (unchecked) common type of [values]
202
209
* @param name the name of the column
0 commit comments