Skip to content

Commit 15cc39e

Browse files
add docs fixes
1 parent d6c5a76 commit 15cc39e

File tree

1 file changed

+19
-16
lines changed
  • core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api

1 file changed

+19
-16
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/add.kt

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
2121
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
2222
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
2323
import org.jetbrains.kotlinx.dataframe.documentation.DocumentationUrls
24+
import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources
2425
import org.jetbrains.kotlinx.dataframe.exceptions.DuplicateColumnNamesException
2526
import org.jetbrains.kotlinx.dataframe.exceptions.UnequalColumnSizesException
2627
import org.jetbrains.kotlinx.dataframe.impl.api.insertImpl
@@ -123,14 +124,21 @@ public interface AddDataRow<out T> : DataRow<T> {
123124
public typealias AddExpression<T, R> = Selector<AddDataRow<T>, R>
124125

125126
/**
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
127139
* adds a new column to the end of this [DataFrame] (at the top level).
128140
*
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]}
134142
*
135143
* Returns a new [DataFrame] with the new column appended to the original list of [DataFrame.columns].
136144
*
@@ -189,11 +197,7 @@ public inline fun <reified R, T> DataFrame<T>.add(
189197
/**
190198
* Creates a new column using [AddExpression] and inserts it at the specified [ColumnPath].
191199
*
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]}
197201
*
198202
* For more information: {@include [DocumentationUrls.Add]}.
199203
*
@@ -344,6 +348,9 @@ public class AddDsl<T>(
344348
* // Add column "is adult" with result of age > 18
345349
* age > 18 into "is adult"
346350
*
351+
* // Add new column "role" using expression
352+
* expr { if ( department == "IT") "developer" else "analyst" } into "role"
353+
*
347354
* // Add column group "details"
348355
* group("details") {
349356
* // 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> {
372379
* Creates a new column using [AddExpression] and
373380
* adds a new column to the end of each group (i.e., [DataFrame]s) of this [GroupBy] (at the top level).
374381
*
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]}
380383
*
381384
* Returns a new [GroupBy] with the new column
382385
* appended to each group [DataFrame] to the original list of [DataFrame.columns].

0 commit comments

Comments
 (0)