@@ -24,15 +24,19 @@ import kotlin.reflect.KProperty
24
24
* from the first cell to the last cell.
25
25
*
26
26
* __NOTE:__ If the column contains nullable values and [skipNA\] is set to `true`,
27
- * null and NaN values are skipped when computing the cumulative sum.
28
- * When false, all values after the first NA will be NaN (for Double and Float columns)
29
- * or null (for integer columns).
27
+ * ` null` and ` NaN` values are skipped when computing the cumulative sum.
28
+ * When ` false` , all values after the first `NA` will be ` NaN` (for [ Double] and [ Float] columns)
29
+ * or ` null` (for other columns).
30
30
*
31
- * {@get [CumSumDocs.CUMSUM_PARAM] @param [columns\]
32
- * The names of the columns to apply cumSum operation.}
31
+ * `cumSum` only works on columns that contain solely primitive numbers.
33
32
*
34
- * @param [skipNA\] Whether to skip null and NaN values (default: `true`) .
33
+ * Similar to [sum][sum], [Byte][Byte]- and [Short][Short]-columns are converted to [Int][Int] .
35
34
*
35
+ * {@get [CumSumDocs.CUMSUM_PARAM] @param [columns\] The selection of the columns to apply the `cumSum` operation to.
36
+ * If not provided, `cumSum` will be applied to all primitive columns [at any depth][ColumnsSelectionDsl.colsAtAnyDepth].
37
+ * }
38
+ *
39
+ * @param [skipNA\] Whether to skip `null` and `NaN` values (default: `true`).
36
40
* @return A new {@get [CumSumDocs.DATA_TYPE]} of the same type with the cumulative sums.
37
41
*
38
42
* {@get [CumSumDocs.CUMSUM_PARAM] @see [Selecting Columns][SelectSelectingOptions].}
@@ -41,8 +45,11 @@ import kotlin.reflect.KProperty
41
45
@ExcludeFromSources
42
46
@Suppress(" ClassName" )
43
47
private interface CumSumDocs {
48
+
49
+ // Can be emptied to disable information about selecting columns
44
50
interface CUMSUM_PARAM
45
51
52
+ // Either [DataColumn] or [DataFrame]
46
53
interface DATA_TYPE
47
54
}
48
55
@@ -159,8 +166,7 @@ public fun <T> DataFrame<T>.cumSum(
159
166
*/
160
167
public fun <T > DataFrame<T>.cumSum (skipNA : Boolean = defaultCumSumSkipNA): DataFrame <T > =
161
168
cumSum(skipNA) {
162
- // TODO keep at any depth?
163
- colsAtAnyDepth().filter { it.isNumber() }.cast()
169
+ colsAtAnyDepth().filter { it.isPrimitiveOrMixedNumber() }.cast()
164
170
}
165
171
166
172
// endregion
@@ -214,8 +220,7 @@ public fun <T, G> GroupBy<T, G>.cumSum(
214
220
*/
215
221
public fun <T , G > GroupBy <T , G >.cumSum (skipNA : Boolean = defaultCumSumSkipNA): GroupBy <T , G > =
216
222
cumSum(skipNA) {
217
- // TODO keep at any depth?
218
- colsAtAnyDepth().filter { it.isNumber() }.cast()
223
+ colsAtAnyDepth().filter { it.isPrimitiveOrMixedNumber() }.cast()
219
224
}
220
225
221
226
// endregion
0 commit comments