Add documentation and tests for DataColumnArithmetics.kt#1769
Add documentation and tests for DataColumnArithmetics.kt#1769
DataColumnArithmetics.kt#1769Conversation
| * using the logical `not` operation: `true` becomes `false`, and `false` becomes `true`.} | ||
| * @set [NOT_RETURN] A [ColumnReference] containing the negated [Boolean] values of this [reference][ColumnReference]. | ||
| */ | ||
| public operator fun ColumnReference<Boolean>.not(): ColumnReference<Boolean> = map { !it } |
There was a problem hiding this comment.
Should we reuse the example for DataColumn (as one of implementations) here and in other cases when ColumnReference is used?
core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/DataColumnArithmetics.kt
Show resolved
Hide resolved
core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/DataColumnArithmetics.kt
Show resolved
Hide resolved
|
|
||
| ## When useful | ||
|
|
||
| In most transformations, these column operations are usually not the preferred approach in Kotlin DataFrame, |
There was a problem hiding this comment.
Not sure if I conveyed the idea in sufficient detail. Is there anything that should be added?
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataColumnArithmetics.kt
Show resolved
Hide resolved
…ove redundant comment.
| * @include [NumberPlusColumnDocs] | ||
| * @set [NUMBER_PLUS_COLUMN_NUMBER_TYPE] [Double] | ||
| * @set [NUMBER_PLUS_COLUMN_EXAMPLE_NUMBER] 10.0 | ||
| * @set [NUMBER_PLUS_COLUMN_SEE_ALSO] [minus][DataColumn.minus], [times][DataColumn.times], [div][DataColumn.div] |
There was a problem hiding this comment.
This refers to DataColumn<Int>.minus(value: Int): DataColumn<Int>.
Isn't there any way to refer to Double.minus(column: DataColumn<Int>) instead?
[minus][Double.minus] doesn't work because it refers to public final operator fun minus(other: Byte): Double from Kotlin.
There was a problem hiding this comment.
nope... [Double.minus] is the closest we can get. If there's multiple matches, the 2026 IDE does give you a list to pick, but there's no way to specify an exact function in KDocs :/ (yet!)
There was a problem hiding this comment.
is sort of mentioned here https://youtrack.jetbrains.com/issue/KT-69919/DM-2024-07-23-Revisit-KDoc-design-Ambiguous-KDoc-references and related issues
| * ```kotlin | ||
| * // Given a DataFrame of financial transactions, | ||
| * // create a column indicating which transactions failed | ||
| * val failed = !df.isSuccessful.rename("failed") |
There was a problem hiding this comment.
hmm, maybe this example could also include an example from inside the selection DSL
There was a problem hiding this comment.
actually, it's not often we work with columns outside a dataframe. we could :) but it's probably best to show it inside a dataframe operation first
|
|
||
| /** | ||
| * @include [NotDocs] | ||
| * @set [NOT_NULL_NOTE] Each `null` value in the original [DataColumn] is preserved. |
There was a problem hiding this comment.
careful mixing block- and inline tags, you can see when you place your cursor here which text is included by this @set tag. Because it doesn't have {} around it, the {@set } below it becomes part of the [NOT_NULL_NOTE]. (okay in practice, the {@set } will be read first and removed from the KDOC, so nothing of it actually enters [NOT_NULL_NOTE], but mixing scopes it generally only a good idea if it's intentional)
In this case, I would turn them all into block tags (so without {}), then each tag continues until it encounters another or the end of the kdoc is reached. Same as @param and @return :)
There was a problem hiding this comment.
the same happens in other places
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataColumnArithmetics.kt
Show resolved
Hide resolved
| * @include [NumberPlusColumnDocs] | ||
| * @set [NUMBER_PLUS_COLUMN_NUMBER_TYPE] [Double] | ||
| * @set [NUMBER_PLUS_COLUMN_EXAMPLE_NUMBER] 10.0 | ||
| * @set [NUMBER_PLUS_COLUMN_SEE_ALSO] [minus][DataColumn.minus], [times][DataColumn.times], [div][DataColumn.div] |
There was a problem hiding this comment.
nope... [Double.minus] is the closest we can get. If there's multiple matches, the 2026 IDE does give you a list to pick, but there's no way to specify an exact function in KDocs :/ (yet!)
| * @include [NumberPlusColumnDocs] | ||
| * @set [NUMBER_PLUS_COLUMN_NUMBER_TYPE] [Double] | ||
| * @set [NUMBER_PLUS_COLUMN_EXAMPLE_NUMBER] 10.0 | ||
| * @set [NUMBER_PLUS_COLUMN_SEE_ALSO] [minus][DataColumn.minus], [times][DataColumn.times], [div][DataColumn.div] |
There was a problem hiding this comment.
is sort of mentioned here https://youtrack.jetbrains.com/issue/KT-69919/DM-2024-07-23-Revisit-KDoc-design-Ambiguous-KDoc-references and related issues
| <!---IMPORT org.jetbrains.kotlinx.dataframe.samples.api.Modify--> | ||
|
|
||
| Kotlin DataFrame provides operators for applying simple arithmetic, logical, string, and comparison operations | ||
| to [`DataColumn`](DataColumn.md) and `ColumnReference` values. These operations include, for example, adding a value to a column, |
There was a problem hiding this comment.
"adding value to each cell in a column"?
| Converts each element of the column to a String and concatenates it with the value. | ||
|
|
||
| ```kotlin | ||
| df.amount + "€" |
There was a problem hiding this comment.
I think only "€" + df.amount would make sense, but that might be something we cannot overload... right?
| df.amount + "€" | ||
| ``` | ||
|
|
||
| `null` values are converted to the string `"null"`. |
Fixes #530
Added:
for
DataColumnArithmetics.kt