@@ -21,6 +21,7 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
21
21
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
22
22
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
23
23
import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls
24
+ import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources
24
25
import org.jetbrains.kotlinx.dataframe.exceptions.DuplicateColumnNamesException
25
26
import org.jetbrains.kotlinx.dataframe.exceptions.UnequalColumnSizesException
26
27
import org.jetbrains.kotlinx.dataframe.impl.api.insertImpl
@@ -123,14 +124,21 @@ public interface AddDataRow<out T> : DataRow<T> {
123
124
public typealias AddExpression <T , R > = Selector <AddDataRow <T >, R >
124
125
125
126
/* *
126
- * Creates a new column using [AddExpression] and
127
+ * With an [AddExpression], you define the value that each row in the new column should have.
128
+ * This can be based on values from the same row in the original [DataFrame].
129
+ *
130
+ * You can also use functions like [prev] and [next] to access other rows, and combine them with
131
+ * [newValue][AddDataRow.newValue] to reference values already computed in the new column.
132
+ * For example, use `prev().newValue()` to access the new column value from the previous row.
133
+ */
134
+ @ExcludeFromSources
135
+ internal interface AddExpressionDocs
136
+
137
+ /* *
138
+ * Creates a new column using an [AddExpression] and
127
139
* adds a new column to the end of this [DataFrame] (at the top level).
128
140
*
129
- * An [AddExpression] allows to compute a value for each row in the new column
130
- * based on the values from that row in the original [DataFrame].
131
- * Also, you can use other methods such as [prev] and [next] to access other rows,
132
- * including [newValue][AddDataRow.newValue] to retrieve already computed values of this column
133
- * in previous rows.
141
+ * {@include [AddExpressionDocs]}
134
142
*
135
143
* Returns a new [DataFrame] with the new column appended to the original list of [DataFrame.columns].
136
144
*
@@ -189,11 +197,7 @@ public inline fun <reified R, T> DataFrame<T>.add(
189
197
/* *
190
198
* Creates a new column using [AddExpression] and inserts it at the specified [ColumnPath].
191
199
*
192
- * An [AddExpression] allows to compute a value for each row in the new column
193
- * based on the values from that row in the original [DataFrame].
194
- * Also, you can use other methods such as [prev] and [next] to access other rows,
195
- * including [newValue][AddDataRow.newValue] to retrieve already computed values of this column
196
- * in previous rows.
200
+ * {@include [AddExpressionDocs]}
197
201
*
198
202
* For more information: {@include [DocumentationUrls.Add]}.
199
203
*
@@ -344,6 +348,9 @@ public class AddDsl<T>(
344
348
* // Add column "is adult" with result of age > 18
345
349
* age > 18 into "is adult"
346
350
*
351
+ * // Add new column "role" using expression
352
+ * expr { if ( department == "IT") "developer" else "analyst" } into "role"
353
+ *
347
354
* // Add column group "details"
348
355
* group("details") {
349
356
* // Add column "last name length" with length of lastName
@@ -372,11 +379,7 @@ public fun <T> DataFrame<T>.add(body: AddDsl<T>.() -> Unit): DataFrame<T> {
372
379
* Creates a new column using [AddExpression] and
373
380
* adds a new column to the end of each group (i.e., [DataFrame]s) of this [GroupBy] (at the top level).
374
381
*
375
- * An [AddExpression] allows to compute a value for each row in the new column
376
- * based on the values from that row in the original group [DataFrame]s.
377
- * Also, you can use other methods such as [prev] and [next] to access other rows,
378
- * including [newValue][AddDataRow.newValue] to retrieve already computed values of this column
379
- * in previous rows.
382
+ * {@include [AddExpressionDocs]}
380
383
*
381
384
* Returns a new [GroupBy] with the new column
382
385
* appended to each group [DataFrame] to the original list of [DataFrame.columns].
0 commit comments