@@ -10,6 +10,7 @@ import org.jetbrains.kotlinx.dataframe.impl.columns.toColumns
10
10
import kotlin.reflect.KProperty
11
11
12
12
/* *
13
+ * ## `NaN`
13
14
* [Floats][Float] or [Doubles][Double] can be represented as [Float.NaN] or [Double.NaN], respectively,
14
15
* in cases where a mathematical operation is undefined, such as dividing by zero.
15
16
*
@@ -21,6 +22,7 @@ import kotlin.reflect.KProperty
21
22
internal interface NaN
22
23
23
24
/* *
25
+ * ## `NA`
24
26
* `NA` in Dataframe can be seen as "[NaN] or `null`".
25
27
*
26
28
* [Floats][Float] or [Doubles][Double] can be represented as [Float.NaN] or [Double.NaN], respectively,
@@ -263,13 +265,21 @@ public fun <T, C> DataFrame<T>.fillNA(columns: Iterable<ColumnReference<C>>): Up
263
265
/* * @param columns The {@include [SelectingColumns.DslLink]} used to select the columns of this [DataFrame] to drop rows in. */
264
266
private interface DropDslParam
265
267
268
+ /* * @param columns The {@include [SelectingColumns.KPropertiesLink]} used to select the columns of this [DataFrame] to drop rows in. */
269
+ private interface DropKPropertiesParam
270
+
271
+ /* * @param columns The {@include [SelectingColumns.ColumnNamesLink]} used to select the columns of this [DataFrame] to drop rows in. */
272
+ private interface DropColumnNamesParam
273
+
274
+ /* * @param columns The {@include [SelectingColumns.ColumnAccessors]} used to select the columns of this [DataFrame] to drop rows in. */
275
+ private interface DropColumnAccessorsParam
266
276
267
277
// region dropNulls
268
278
269
279
/* *
270
280
* ## The Drop Nulls Operation
271
281
*
272
- * Removes rows with `null` values.
282
+ * Removes rows with `null` values. Specific case of [drop][DataFrame.drop].
273
283
*
274
284
* Optionally, you can select which columns to operate on (see {@include [SelectingColumnsLink]}).
275
285
* Also, you can supply `whereAllNull = true` to only drop rows where all selected cells are `null`. By default,
@@ -300,7 +310,6 @@ private interface CommonDropNullsFunctionDoc
300
310
* @include [CommonDropNullsFunctionDoc]
301
311
* @include [SelectingColumns.Dsl.WithExample] {@include [SetDropNullsOperationArg]}
302
312
* `df.`[dropNulls][dropNulls]`(whereAllNull = true) { `[colsOf][colsOf]`<`[Double][Double]`>() }`
303
- *
304
313
* @include [DropNulls.WhereAllNullParam]
305
314
* @include [DropDslParam]
306
315
*/
@@ -323,7 +332,7 @@ public fun <T> DataFrame<T>.dropNulls(whereAllNull: Boolean = false): DataFrame<
323
332
* @include [SelectingColumns.KProperties.WithExample] {@include [SetDropNullsOperationArg]}
324
333
* `df.`[dropNulls][dropNulls]`(Person::length, whereAllNull = true)`
325
334
* @include [DropNulls.WhereAllNullParam]
326
- * @include [DropDslParam ]
335
+ * @include [DropKPropertiesParam ]
327
336
*/
328
337
public fun <T > DataFrame<T>.dropNulls (vararg columns : KProperty <* >, whereAllNull : Boolean = false): DataFrame <T > =
329
338
dropNulls(whereAllNull) { columns.toColumns() }
@@ -333,7 +342,7 @@ public fun <T> DataFrame<T>.dropNulls(vararg columns: KProperty<*>, whereAllNull
333
342
* @include [SelectingColumns.ColumnNames.WithExample] {@include [SetDropNullsOperationArg]}
334
343
* `df.`[dropNulls][dropNulls]`("length", whereAllNull = true)`
335
344
* @include [DropNulls.WhereAllNullParam]
336
- * @include [DropDslParam ]
345
+ * @include [DropColumnNamesParam ]
337
346
*/
338
347
public fun <T > DataFrame<T>.dropNulls (vararg columns : String , whereAllNull : Boolean = false): DataFrame <T > =
339
348
dropNulls(whereAllNull) { columns.toColumns() }
@@ -343,7 +352,7 @@ public fun <T> DataFrame<T>.dropNulls(vararg columns: String, whereAllNull: Bool
343
352
* @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetDropNullsOperationArg]}
344
353
* `df.`[dropNulls][dropNulls]`(length, whereAllNull = true)`
345
354
* @include [DropNulls.WhereAllNullParam]
346
- * @include [DropDslParam ]
355
+ * @include [DropColumnAccessorsParam ]
347
356
*/
348
357
public fun <T > DataFrame<T>.dropNulls (vararg columns : AnyColumnReference , whereAllNull : Boolean = false): DataFrame <T > =
349
358
dropNulls(whereAllNull) { columns.toColumns() }
@@ -353,7 +362,7 @@ public fun <T> DataFrame<T>.dropNulls(vararg columns: AnyColumnReference, whereA
353
362
*/
354
363
public fun <T > DataFrame<T>.dropNulls (
355
364
columns : Iterable <AnyColumnReference >,
356
- whereAllNull : Boolean = false
365
+ whereAllNull : Boolean = false,
357
366
): DataFrame <T > =
358
367
dropNulls(whereAllNull) { columns.toColumnSet() }
359
368
@@ -369,28 +378,98 @@ public fun <T> DataColumn<T?>.dropNulls(): DataColumn<T> =
369
378
370
379
// region dropNA
371
380
372
- public fun <T > DataFrame<T>.dropNA (whereAllNA : Boolean = false, selector : ColumnsSelector <T , * >): DataFrame <T > {
373
- val columns = this [selector]
381
+ /* *
382
+ * ## The Drop `NA` Operation
383
+ *
384
+ * Removes rows with [`NA`][NA] values. Specific case of [drop][DataFrame.drop].
385
+ *
386
+ * Optionally, you can select which columns to operate on (see {@include [SelectingColumnsLink]}).
387
+ * Also, you can supply `whereAllNA = true` to only drop rows where all selected cells are [`NA`][NA]. By default,
388
+ * rows are dropped if any of the selected cells are [`NA`][NA].
389
+ *
390
+ * For more information: {@include [DocumentationUrls.Drop.DropNA]}
391
+ */
392
+ internal interface DropNA {
393
+
394
+ /* *
395
+ * @param whereAllNA `false` by default.
396
+ * If `true`, rows are dropped if all selected cells are [`NA`][NA].
397
+ * If `false`, rows are dropped if any of the selected cells is [`NA`][NA].
398
+ */
399
+ interface WhereAllNAParam
400
+ }
401
+
402
+ /* * {@arg [SelectingColumns.OperationArg] [dropNA][dropNA]} */
403
+ private interface SetDropNAOperationArg
404
+
405
+ /* *
406
+ * @include [DropNA] {@comment Description of the dropNA operation.}
407
+ * ## This Drop NA Overload
408
+ */
409
+ private interface CommonDropNAFunctionDoc
374
410
375
- return if (whereAllNA) drop { columns.all { this [it].isNA } }
376
- else drop { columns.any { this [it].isNA } }
411
+ /* *
412
+ * @include [CommonDropNAFunctionDoc]
413
+ * @include [SelectingColumns.Dsl.WithExample] {@include [SetDropNAOperationArg]}
414
+ * `df.`[dropNA][dropNA]`(whereAllNA = true) { `[colsOf][colsOf]`<`[Double][Double]`>() }`
415
+ * @include [DropNA.WhereAllNAParam]
416
+ * @include [DropDslParam]
417
+ */
418
+ public fun <T > DataFrame<T>.dropNA (whereAllNA : Boolean = false, columns : ColumnsSelector <T , * >): DataFrame <T > {
419
+ val cols = this [columns]
420
+ return if (whereAllNA) drop { cols.all { this [it].isNA } }
421
+ else drop { cols.any { this [it].isNA } }
377
422
}
378
423
424
+ /* *
425
+ * @include [CommonDropNAFunctionDoc]
426
+ * @include [SelectingColumns.KProperties.WithExample] {@include [SetDropNAOperationArg]}
427
+ * `df.`[dropNA][dropNA]`(Person::length, whereAllNA = true)`
428
+ * @include [DropNA.WhereAllNAParam]
429
+ * @include [DropKPropertiesParam]
430
+ */
379
431
public fun <T > DataFrame<T>.dropNA (vararg columns : KProperty <* >, whereAllNA : Boolean = false): DataFrame <T > =
380
432
dropNA(whereAllNA) { columns.toColumns() }
381
433
434
+ /* *
435
+ * @include [CommonDropNAFunctionDoc]
436
+ * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetDropNAOperationArg]}
437
+ * `df.`[dropNA][dropNA]`("length", whereAllNA = true)`
438
+ * @include [DropNA.WhereAllNAParam]
439
+ * @include [DropColumnNamesParam]
440
+ */
382
441
public fun <T > DataFrame<T>.dropNA (vararg columns : String , whereAllNA : Boolean = false): DataFrame <T > =
383
442
dropNA(whereAllNA) { columns.toColumns() }
384
443
444
+ /* *
445
+ * @include [CommonDropNAFunctionDoc]
446
+ * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetDropNAOperationArg]}
447
+ * `df.`[dropNA][dropNA]`(length, whereAllNA = true)`
448
+ * @include [DropNA.WhereAllNAParam]
449
+ * @include [DropColumnAccessorsParam]
450
+ */
385
451
public fun <T > DataFrame<T>.dropNA (vararg columns : AnyColumnReference , whereAllNA : Boolean = false): DataFrame <T > =
386
452
dropNA(whereAllNA) { columns.toColumns() }
387
453
454
+ /* *
455
+ * TODO will be deprecated
456
+ */
388
457
public fun <T > DataFrame<T>.dropNA (columns : Iterable <AnyColumnReference >, whereAllNA : Boolean = false): DataFrame <T > =
389
458
dropNA(whereAllNA) { columns.toColumnSet() }
390
459
460
+ /* *
461
+ * @include [CommonDropNAFunctionDoc]
462
+ * This overload operates on all columns in the [DataFrame].
463
+ * @include [DropNA.WhereAllNAParam]
464
+ */
391
465
public fun <T > DataFrame<T>.dropNA (whereAllNA : Boolean = false): DataFrame <T > =
392
466
dropNA(whereAllNA) { all() }
393
467
468
+ /* *
469
+ * ## The Drop `NA` Operation
470
+ *
471
+ * Removes [`NA`][NA] values from this [DataColumn], adjusting the type accordingly.
472
+ */
394
473
public fun <T > DataColumn<T?>.dropNA (): DataColumn <T > =
395
474
when (typeClass) {
396
475
Double ::class , Float ::class -> filter { ! it.isNA }.cast()
@@ -401,28 +480,98 @@ public fun <T> DataColumn<T?>.dropNA(): DataColumn<T> =
401
480
402
481
// region dropNaNs
403
482
404
- public fun <T > DataFrame<T>.dropNaNs (whereAllNaN : Boolean = false, selector : ColumnsSelector <T , * >): DataFrame <T > {
405
- val cols = this [selector]
483
+ /* *
484
+ * ## The Drop `NaN` Operation
485
+ *
486
+ * Removes rows with [`NaN`][Double.isNaN] values. Specific case of [drop][DataFrame.drop].
487
+ *
488
+ * Optionally, you can select which columns to operate on (see {@include [SelectingColumnsLink]}).
489
+ * Also, you can supply `whereAllNaN = true` to only drop rows where all selected cells are [`NaN`][Double.isNaN]. By default,
490
+ * rows are dropped if any of the selected cells are [`NaN`][Double.isNaN].
491
+ *
492
+ * For more information: {@include [DocumentationUrls.Drop.DropNaNs]}
493
+ */
494
+ internal interface DropNaNs {
495
+
496
+ /* *
497
+ * @param whereAllNaN `false` by default.
498
+ * If `true`, rows are dropped if all selected cells are [`NaN`][Double.isNaN].
499
+ * If `false`, rows are dropped if any of the selected cells is [`NaN`][Double.isNaN].
500
+ */
501
+ interface WhereAllNaNParam
502
+ }
503
+
504
+ /* * {@arg [SelectingColumns.OperationArg] [dropNaNs][dropNaNs]} */
505
+ private interface SetDropNaNsOperationArg
406
506
507
+ /* *
508
+ * @include [DropNaNs] {@comment Description of the dropNaNs operation.}
509
+ * ## This Drop NaNs Overload
510
+ */
511
+ private interface CommonDropNaNsFunctionDoc
512
+
513
+ /* *
514
+ * @include [CommonDropNaNsFunctionDoc]
515
+ * @include [SelectingColumns.Dsl.WithExample] {@include [SetDropNaNsOperationArg]}
516
+ * `df.`[dropNaNs][dropNaNs]`(whereAllNaN = true) { `[colsOf][colsOf]`<`[Double][Double]`>() }`
517
+ * @include [DropNaNs.WhereAllNaNParam]
518
+ * @include [DropDslParam]
519
+ */
520
+ public fun <T > DataFrame<T>.dropNaNs (whereAllNaN : Boolean = false, columns : ColumnsSelector <T , * >): DataFrame <T > {
521
+ val cols = this [columns]
407
522
return if (whereAllNaN) drop { cols.all { this [it].isNaN } }
408
523
else drop { cols.any { this [it].isNaN } }
409
524
}
410
525
411
- public fun <T > DataFrame<T>.dropNaNs (vararg cols : KProperty <* >, whereAllNaN : Boolean = false): DataFrame <T > =
412
- dropNaNs(whereAllNaN) { cols.toColumns() }
526
+ /* *
527
+ * @include [CommonDropNaNsFunctionDoc]
528
+ * @include [SelectingColumns.KProperties.WithExample] {@include [SetDropNaNsOperationArg]}
529
+ * `df.`[dropNaNs][dropNaNs]`(Person::length, whereAllNaN = true)`
530
+ * @include [DropNaNs.WhereAllNaNParam]
531
+ * @include [DropKPropertiesParam]
532
+ */
533
+ public fun <T > DataFrame<T>.dropNaNs (vararg columns : KProperty <* >, whereAllNaN : Boolean = false): DataFrame <T > =
534
+ dropNaNs(whereAllNaN) { columns.toColumns() }
413
535
414
- public fun <T > DataFrame<T>.dropNaNs (vararg cols : String , whereAllNaN : Boolean = false): DataFrame <T > =
415
- dropNaNs(whereAllNaN) { cols.toColumns() }
536
+ /* *
537
+ * @include [CommonDropNaNsFunctionDoc]
538
+ * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetDropNaNsOperationArg]}
539
+ * `df.`[dropNaNs][dropNaNs]`("length", whereAllNaN = true)`
540
+ * @include [DropNaNs.WhereAllNaNParam]
541
+ * @include [DropColumnNamesParam]
542
+ */
543
+ public fun <T > DataFrame<T>.dropNaNs (vararg columns : String , whereAllNaN : Boolean = false): DataFrame <T > =
544
+ dropNaNs(whereAllNaN) { columns.toColumns() }
416
545
417
- public fun <T > DataFrame<T>.dropNaNs (vararg cols : AnyColumnReference , whereAllNaN : Boolean = false): DataFrame <T > =
418
- dropNaNs(whereAllNaN) { cols.toColumns() }
546
+ /* *
547
+ * @include [CommonDropNaNsFunctionDoc]
548
+ * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetDropNaNsOperationArg]}
549
+ * `df.`[dropNaNs][dropNaNs]`(length, whereAllNaN = true)`
550
+ * @include [DropNaNs.WhereAllNaNParam]
551
+ * @include [DropColumnAccessorsParam]
552
+ */
553
+ public fun <T > DataFrame<T>.dropNaNs (vararg columns : AnyColumnReference , whereAllNaN : Boolean = false): DataFrame <T > =
554
+ dropNaNs(whereAllNaN) { columns.toColumns() }
419
555
420
- public fun <T > DataFrame<T>.dropNaNs (cols : Iterable <AnyColumnReference >, whereAllNaN : Boolean = false): DataFrame <T > =
421
- dropNaNs(whereAllNaN) { cols.toColumnSet() }
556
+ /* *
557
+ * TODO will be deprecated
558
+ */
559
+ public fun <T > DataFrame<T>.dropNaNs (columns : Iterable <AnyColumnReference >, whereAllNaN : Boolean = false): DataFrame <T > =
560
+ dropNaNs(whereAllNaN) { columns.toColumnSet() }
422
561
562
+ /* *
563
+ * @include [CommonDropNaNsFunctionDoc]
564
+ * This overload operates on all columns in the [DataFrame].
565
+ * @include [DropNaNs.WhereAllNaNParam]
566
+ */
423
567
public fun <T > DataFrame<T>.dropNaNs (whereAllNaN : Boolean = false): DataFrame <T > =
424
568
dropNaNs(whereAllNaN) { all() }
425
569
570
+ /* *
571
+ * ## The Drop `NaN` Operation
572
+ *
573
+ * Removes [`NaN`][NaN] values from this [DataColumn], adjusting the type accordingly.
574
+ */
426
575
public fun <T > DataColumn<T>.dropNaNs (): DataColumn <T > =
427
576
when (typeClass) {
428
577
Double ::class , Float ::class -> filter { ! it.isNaN }.cast()
0 commit comments