Skip to content

Commit b4fd200

Browse files
committed
adding docs based on feedback
1 parent 348b84b commit b4fd200

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,17 @@ public fun <T, C> DataFrame<T>.fillNulls(vararg columns: ColumnReference<C>): Up
100100

101101
// endregion
102102

103+
/** Is only `true` if [this] is [Double.NaN] or [Float.NaN]. */
103104
internal inline val Any?.isNaN: Boolean get() = (this is Double && isNaN()) || (this is Float && isNaN())
104105

106+
/**
107+
* Returns `true` if [this] is considered NA.
108+
* "NA", in DataFrame, roughly means `null` or `NaN`.
109+
*
110+
* Overload of `isNA` with contract support.
111+
*
112+
* @see NA
113+
*/
105114
@JvmName("isNaWithContract")
106115
@Suppress("NOTHING_TO_INLINE")
107116
@OptIn(ExperimentalContracts::class)
@@ -110,6 +119,11 @@ internal inline fun <T : Any?> T.isNA(): Boolean {
110119
return isNA
111120
}
112121

122+
/**
123+
* Is `true` if [this] is considered NA.
124+
* "NA", in DataFrame, roughly means `null` or `NaN`.
125+
* @see NA
126+
*/
113127
internal inline val Any?.isNA: Boolean
114128
get() = when (this) {
115129
null -> true
@@ -122,10 +136,22 @@ internal inline val Any?.isNA: Boolean
122136

123137
internal inline val AnyCol.canHaveNaN: Boolean get() = typeClass.let { it == Double::class || it == Float::class }
124138

139+
/**
140+
* Is `true` when [this] column can have [NA] values.
141+
* @see NA
142+
*/
125143
internal inline val AnyCol.canHaveNA: Boolean get() = hasNulls() || canHaveNaN || kind() != ColumnKind.Value
126144

145+
/**
146+
* Is `true` when [this] is `null` or [Double.NaN].
147+
* @see NA
148+
*/
127149
internal inline val Double?.isNA: Boolean get() = this == null || this.isNaN()
128150

151+
/**
152+
* Is `true` when [this] is `null` or [Float.NaN].
153+
* @see NA
154+
*/
129155
internal inline val Float?.isNA: Boolean get() = this == null || this.isNaN()
130156

131157
// region fillNaNs

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/NA.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.jetbrains.kotlinx.dataframe.documentation
22

3+
import org.jetbrains.kotlinx.dataframe.DataFrame
4+
import org.jetbrains.kotlinx.dataframe.DataRow
35
import org.jetbrains.kotlinx.dataframe.api.dropNA
46
import org.jetbrains.kotlinx.dataframe.api.fillNA
57

@@ -10,6 +12,10 @@ import org.jetbrains.kotlinx.dataframe.api.fillNA
1012
* [Floats][Float] or [Doubles][Double] can be represented as [Float.NaN] or [Double.NaN], respectively,
1113
* in cases where a mathematical operation is undefined, such as dividing by zero.
1214
*
15+
* A [DataRow] can also be considered `NA` if each value inside is `NA`.
16+
*
17+
* A [DataFrame] is considered `NA` if it has no rows or columns, so if it's empty.
18+
*
1319
* You can also use [fillNA][fillNA] to replace `NAs` in certain columns with a given value or expression
1420
* or [dropNA][dropNA] to drop rows with `NAs` in them.
1521
*

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/math/minMax.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private fun <T : Comparable<T>> Sequence<T>.bestOrNull(
5858
error(
5959
"Encountered non-comparable type ${
6060
renderType(type)
61-
} in $name function. Only self-comparable types are supported.",
61+
} in $name function. Try converting the values to the same type `T : Comparable<T>`.",
6262
)
6363
}
6464

0 commit comments

Comments
 (0)