@@ -17,24 +17,34 @@ import kotlin.reflect.KProperty
17
17
18
18
// region fillNulls
19
19
20
- public fun <T , C > DataFrame<T>.fillNulls (cols : ColumnsSelector <T , C >): Update <T , C > = update(cols).where { it == null }
21
- public fun <T > DataFrame<T>.fillNulls (vararg cols : String ): Update <T , Any ?> = fillNulls { cols.toColumns() }
22
- public fun <T , C > DataFrame<T>.fillNulls (vararg cols : KProperty <C >): Update <T , C > = fillNulls { cols.toColumns() }
23
- public fun <T , C > DataFrame<T>.fillNulls (vararg cols : ColumnReference <C >): Update <T , C > = fillNulls { cols.toColumns() }
24
- public fun <T , C > DataFrame<T>.fillNulls (cols : Iterable <ColumnReference <C >>): Update <T , C > = fillNulls { cols.toColumnSet() }
20
+ public fun <T , C > DataFrame<T>.fillNulls (cols : ColumnsSelector <T , C ?>): Update <T , C ?> =
21
+ update(cols).where { it == null }
22
+
23
+ public fun <T > DataFrame<T>.fillNulls (vararg cols : String ): Update <T , Any ?> =
24
+ fillNulls { cols.toColumns() }
25
+
26
+ public fun <T , C > DataFrame<T>.fillNulls (vararg cols : KProperty <C >): Update <T , C ?> =
27
+ fillNulls { cols.toColumns() }
28
+
29
+ public fun <T , C > DataFrame<T>.fillNulls (vararg cols : ColumnReference <C >): Update <T , C ?> =
30
+ fillNulls { cols.toColumns() }
31
+
32
+ public fun <T , C > DataFrame<T>.fillNulls (cols : Iterable <ColumnReference <C >>): Update <T , C ?> =
33
+ fillNulls { cols.toColumnSet() }
25
34
26
35
// endregion
27
36
28
37
internal inline val Any? .isNaN: Boolean get() = (this is Double && isNaN()) || (this is Float && isNaN())
29
38
30
- internal inline val Any? .isNA: Boolean get() = when (this ) {
31
- null -> true
32
- is Double -> isNaN()
33
- is Float -> isNaN()
34
- is AnyRow -> allNA()
35
- is AnyFrame -> isEmpty()
36
- else -> false
37
- }
39
+ internal inline val Any? .isNA: Boolean
40
+ get() = when (this ) {
41
+ null -> true
42
+ is Double -> isNaN()
43
+ is Float -> isNaN()
44
+ is AnyRow -> allNA()
45
+ is AnyFrame -> isEmpty()
46
+ else -> false
47
+ }
38
48
39
49
internal inline val AnyCol .canHaveNaN: Boolean get() = typeClass.let { it == Double ::class || it == Float ::class }
40
50
@@ -46,21 +56,39 @@ internal inline val Float?.isNA: Boolean get() = this == null || this.isNaN()
46
56
47
57
// region fillNaNs
48
58
49
- public fun <T , C > DataFrame<T>.fillNaNs (cols : ColumnsSelector <T , C >): Update <T , C > = update(cols).where { it.isNaN }
50
- public fun <T > DataFrame<T>.fillNaNs (vararg cols : String ): Update <T , Any ?> = fillNaNs { cols.toColumns() }
51
- public fun <T , C > DataFrame<T>.fillNaNs (vararg cols : KProperty <C >): Update <T , C > = fillNaNs { cols.toColumns() }
52
- public fun <T , C > DataFrame<T>.fillNaNs (vararg cols : ColumnReference <C >): Update <T , C > = fillNaNs { cols.toColumns() }
53
- public fun <T , C > DataFrame<T>.fillNaNs (cols : Iterable <ColumnReference <C >>): Update <T , C > = fillNaNs { cols.toColumnSet() }
59
+ public fun <T , C > DataFrame<T>.fillNaNs (cols : ColumnsSelector <T , C >): Update <T , C > =
60
+ update(cols).where { it.isNaN }
61
+
62
+ public fun <T > DataFrame<T>.fillNaNs (vararg cols : String ): Update <T , Any ?> =
63
+ fillNaNs { cols.toColumns() }
64
+
65
+ public fun <T , C > DataFrame<T>.fillNaNs (vararg cols : KProperty <C >): Update <T , C > =
66
+ fillNaNs { cols.toColumns() }
67
+
68
+ public fun <T , C > DataFrame<T>.fillNaNs (vararg cols : ColumnReference <C >): Update <T , C > =
69
+ fillNaNs { cols.toColumns() }
70
+
71
+ public fun <T , C > DataFrame<T>.fillNaNs (cols : Iterable <ColumnReference <C >>): Update <T , C > =
72
+ fillNaNs { cols.toColumnSet() }
54
73
55
74
// endregion
56
75
57
76
// region fillNA
58
77
59
- public fun <T , C > DataFrame<T>.fillNA (cols : ColumnsSelector <T , C >): Update <T , C > = update(cols).where { it.isNA }
60
- public fun <T > DataFrame<T>.fillNA (vararg cols : String ): Update <T , Any ?> = fillNA { cols.toColumns() }
61
- public fun <T , C > DataFrame<T>.fillNA (vararg cols : KProperty <C >): Update <T , C > = fillNA { cols.toColumns() }
62
- public fun <T , C > DataFrame<T>.fillNA (vararg cols : ColumnReference <C >): Update <T , C > = fillNA { cols.toColumns() }
63
- public fun <T , C > DataFrame<T>.fillNA (cols : Iterable <ColumnReference <C >>): Update <T , C > = fillNA { cols.toColumnSet() }
78
+ public fun <T , C > DataFrame<T>.fillNA (cols : ColumnsSelector <T , C ?>): Update <T , C ?> =
79
+ update(cols).where { it.isNA }
80
+
81
+ public fun <T > DataFrame<T>.fillNA (vararg cols : String ): Update <T , Any ?> =
82
+ fillNA { cols.toColumns() }
83
+
84
+ public fun <T , C > DataFrame<T>.fillNA (vararg cols : KProperty <C >): Update <T , C ?> =
85
+ fillNA { cols.toColumns() }
86
+
87
+ public fun <T , C > DataFrame<T>.fillNA (vararg cols : ColumnReference <C >): Update <T , C ?> =
88
+ fillNA { cols.toColumns() }
89
+
90
+ public fun <T , C > DataFrame<T>.fillNA (cols : Iterable <ColumnReference <C >>): Update <T , C ?> =
91
+ fillNA { cols.toColumnSet() }
64
92
65
93
// endregion
66
94
@@ -72,13 +100,23 @@ public fun <T> DataFrame<T>.dropNulls(whereAllNull: Boolean = false, selector: C
72
100
else drop { row -> cols.any { col -> col[row] == null } }
73
101
}
74
102
75
- public fun <T > DataFrame<T>.dropNulls (whereAllNull : Boolean = false): DataFrame <T > = dropNulls(whereAllNull) { all() }
76
- public fun <T > DataFrame<T>.dropNulls (vararg cols : KProperty <* >, whereAllNull : Boolean = false): DataFrame <T > = dropNulls(whereAllNull) { cols.toColumns() }
77
- public fun <T > DataFrame<T>.dropNulls (vararg cols : String , whereAllNull : Boolean = false): DataFrame <T > = dropNulls(whereAllNull) { cols.toColumns() }
78
- public fun <T > DataFrame<T>.dropNulls (vararg cols : Column , whereAllNull : Boolean = false): DataFrame <T > = dropNulls(whereAllNull) { cols.toColumns() }
79
- public fun <T > DataFrame<T>.dropNulls (cols : Iterable <Column >, whereAllNull : Boolean = false): DataFrame <T > = dropNulls(whereAllNull) { cols.toColumnSet() }
103
+ public fun <T > DataFrame<T>.dropNulls (whereAllNull : Boolean = false): DataFrame <T > =
104
+ dropNulls(whereAllNull) { all() }
105
+
106
+ public fun <T > DataFrame<T>.dropNulls (vararg cols : KProperty <* >, whereAllNull : Boolean = false): DataFrame <T > =
107
+ dropNulls(whereAllNull) { cols.toColumns() }
108
+
109
+ public fun <T > DataFrame<T>.dropNulls (vararg cols : String , whereAllNull : Boolean = false): DataFrame <T > =
110
+ dropNulls(whereAllNull) { cols.toColumns() }
111
+
112
+ public fun <T > DataFrame<T>.dropNulls (vararg cols : Column , whereAllNull : Boolean = false): DataFrame <T > =
113
+ dropNulls(whereAllNull) { cols.toColumns() }
80
114
81
- public fun <T > DataColumn<T?>.dropNulls (): DataColumn <T > = (if (! hasNulls()) this else filter { it != null }) as DataColumn <T >
115
+ public fun <T > DataFrame<T>.dropNulls (cols : Iterable <Column >, whereAllNull : Boolean = false): DataFrame <T > =
116
+ dropNulls(whereAllNull) { cols.toColumnSet() }
117
+
118
+ public fun <T > DataColumn<T?>.dropNulls (): DataColumn <T > =
119
+ (if (! hasNulls()) this else filter { it != null }) as DataColumn <T >
82
120
83
121
// endregion
84
122
@@ -91,16 +129,25 @@ public fun <T> DataFrame<T>.dropNA(whereAllNA: Boolean = false, selector: Column
91
129
else drop { cols.any { this [it].isNA } }
92
130
}
93
131
94
- public fun <T > DataFrame<T>.dropNA (vararg cols : KProperty <* >, whereAllNA : Boolean = false): DataFrame <T > = dropNA(whereAllNA) { cols.toColumns() }
95
- public fun <T > DataFrame<T>.dropNA (vararg cols : String , whereAllNA : Boolean = false): DataFrame <T > = dropNA(whereAllNA) { cols.toColumns() }
96
- public fun <T > DataFrame<T>.dropNA (vararg cols : Column , whereAllNA : Boolean = false): DataFrame <T > = dropNA(whereAllNA) { cols.toColumns() }
97
- public fun <T > DataFrame<T>.dropNA (cols : Iterable <Column >, whereAllNA : Boolean = false): DataFrame <T > = dropNA(whereAllNA) { cols.toColumnSet() }
132
+ public fun <T > DataFrame<T>.dropNA (vararg cols : KProperty <* >, whereAllNA : Boolean = false): DataFrame <T > =
133
+ dropNA(whereAllNA) { cols.toColumns() }
98
134
99
- public fun <T > DataFrame<T>.dropNA (whereAllNA : Boolean = false): DataFrame <T > = dropNA(whereAllNA) { all() }
135
+ public fun <T > DataFrame<T>.dropNA (vararg cols : String , whereAllNA : Boolean = false): DataFrame <T > =
136
+ dropNA(whereAllNA) { cols.toColumns() }
100
137
101
- public fun <T > DataColumn<T?>.dropNA (): DataColumn <T > = when (typeClass) {
102
- Double ::class , Float ::class -> filter { ! it.isNA }.cast()
103
- else -> (if (! hasNulls()) this else filter { it != null }) as DataColumn <T >
104
- }
138
+ public fun <T > DataFrame<T>.dropNA (vararg cols : Column , whereAllNA : Boolean = false): DataFrame <T > =
139
+ dropNA(whereAllNA) { cols.toColumns() }
140
+
141
+ public fun <T > DataFrame<T>.dropNA (cols : Iterable <Column >, whereAllNA : Boolean = false): DataFrame <T > =
142
+ dropNA(whereAllNA) { cols.toColumnSet() }
143
+
144
+ public fun <T > DataFrame<T>.dropNA (whereAllNA : Boolean = false): DataFrame <T > =
145
+ dropNA(whereAllNA) { all() }
146
+
147
+ public fun <T > DataColumn<T?>.dropNA (): DataColumn <T > =
148
+ when (typeClass) {
149
+ Double ::class , Float ::class -> filter { ! it.isNA }.cast()
150
+ else -> (if (! hasNulls()) this else filter { it != null }) as DataColumn <T >
151
+ }
105
152
106
153
// endregion
0 commit comments