df-script 1.9.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -235
- package/dist/api.d.ts +41 -36
- package/dist/columnExpressions/ColumnExpr.d.ts +5 -8
- package/dist/columnExpressions/functions/all.d.ts +13 -13
- package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
- package/dist/columnExpressions/functions/duration.d.ts +16 -21
- package/dist/columnExpressions/functions/element.d.ts +10 -10
- package/dist/columnExpressions/functions/exclude.d.ts +14 -14
- package/dist/columnExpressions/functions/implode.d.ts +7 -7
- package/dist/columnExpressions/functions/lit.d.ts +9 -9
- package/dist/columnExpressions/functions/seqRange.d.ts +69 -0
- package/dist/columnExpressions/functions/struct.d.ts +6 -6
- package/dist/columnExpressions/functions/when.d.ts +25 -28
- package/dist/columnExpressions/index.d.ts +3 -7
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +550 -221
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +701 -327
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +508 -212
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +398 -201
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +59 -29
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +23 -9
- package/dist/columnExpressions/mixins/StandardExpr.d.ts +3234 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +1163 -524
- package/dist/columnExpressions/mixins/StructExpr.d.ts +67 -25
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +518 -212
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +270 -102
- package/dist/columnExpressions/typeInference.d.ts +3 -3
- package/dist/columnExpressions/types.d.ts +5 -0
- package/dist/columnExpressions/utils.d.ts +7 -0
- package/dist/constants.d.ts +11 -2
- package/dist/dataframe/dataframe.d.ts +755 -592
- package/dist/dataframe/grouped/grouped.d.ts +24 -6
- package/dist/dataframe/grouped.d.ts +70 -0
- package/dist/dataframe/index.d.ts +1 -1
- package/dist/dataframe/lazy.d.ts +37 -0
- package/dist/dataframe/types.d.ts +46 -22
- package/dist/dataframe/utils.d.ts +10 -4
- package/dist/datatypes/index.d.ts +11 -4
- package/dist/expressions.js +1 -0
- package/dist/expressions.mjs +1 -0
- package/dist/functions/concat.d.ts +68 -16
- package/dist/functions/index.d.ts +2 -2
- package/dist/functions/readCsv.d.ts +35 -0
- package/dist/functions/readJson.d.ts +33 -0
- package/dist/index.js +5 -6
- package/dist/index.mjs +5 -6
- package/dist/types.d.ts +42 -9
- package/dist/utils/array.d.ts +17 -14
- package/dist/utils/csv.d.ts +4 -1
- package/dist/utils/date.d.ts +3 -19
- package/dist/utils/duration.d.ts +7 -5
- package/dist/utils/json.d.ts +5 -3
- package/dist/utils/object.d.ts +0 -18
- package/dist/utils/string.d.ts +5 -0
- package/dist/utils.js +4 -0
- package/dist/utils.mjs +4 -0
- package/package.json +29 -8
- package/dist/assets/index-DBhGK6Tp.css +0 -1
- package/dist/assets/index-DEJEV_tU.js +0 -195
- package/dist/index.html +0 -17
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExprBase } from "../ExprBase";
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
2
|
+
import { UniqueArrayStatsOptions, StepSliceArrayOptions, JoinArrayOptions } from "../../utils";
|
|
3
|
+
import type { SortArrayOptions, ExplodeOptions, IExpr, AnyTypedArray, ToStructOptions } from "../../types";
|
|
4
4
|
/**
|
|
5
5
|
* @namespace $df.col.arr
|
|
6
6
|
* @category ColumnExpression
|
|
@@ -10,13 +10,22 @@ export declare class ArrayExprNamespace {
|
|
|
10
10
|
expr: any;
|
|
11
11
|
constructor(expr: any);
|
|
12
12
|
_deriveArray(fn: (arr: any[] | AnyTypedArray) => any): any;
|
|
13
|
+
_deriveArrayBinary(other: any, fn: (arr: any[] | AnyTypedArray, val: any) => any): any;
|
|
13
14
|
/**
|
|
14
15
|
* Applies an aggregation expression or element-wise calculation over each array cell.
|
|
15
16
|
* @param expr Aggregation expression (e.g. $df.element().sum() or $df.element().max())
|
|
16
17
|
* @returns ColumnExpression
|
|
17
18
|
* @example
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
20
|
+
* >>> df
|
|
21
|
+
* shape: (2, 1)
|
|
22
|
+
* ┌───────────┐
|
|
23
|
+
* │ a │
|
|
24
|
+
* ├───────────┤
|
|
25
|
+
* │ [1, 2, 3] │
|
|
26
|
+
* │ [4, 5] │
|
|
27
|
+
* └───────────┘
|
|
28
|
+
* >>> df.withColumns($df.col("a").arr.agg($df.element().sum()).alias("sum_a"))
|
|
20
29
|
* shape: (2, 2)
|
|
21
30
|
* ┌───────────┬───────┐
|
|
22
31
|
* │ a │ sum_a │
|
|
@@ -30,8 +39,16 @@ export declare class ArrayExprNamespace {
|
|
|
30
39
|
* Returns true if all items in nested list cells are truthy.
|
|
31
40
|
* @returns ColumnExpression
|
|
32
41
|
* @example
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
43
|
+
* >>> df
|
|
44
|
+
* shape: (2, 1)
|
|
45
|
+
* ┌───────────┐
|
|
46
|
+
* │ a │
|
|
47
|
+
* ├───────────┤
|
|
48
|
+
* │ [1, 2, 3] │
|
|
49
|
+
* │ [4, 5] │
|
|
50
|
+
* └───────────┘
|
|
51
|
+
* >>> df.withColumns($df.col("a").arr.all().alias("all_true"))
|
|
35
52
|
* shape: (2, 2)
|
|
36
53
|
* ┌───────────────┬──────────┐
|
|
37
54
|
* │ a │ all_true │
|
|
@@ -45,54 +62,86 @@ export declare class ArrayExprNamespace {
|
|
|
45
62
|
* Returns true if any item in nested list cells is truthy.
|
|
46
63
|
* @returns ColumnExpression
|
|
47
64
|
* @example
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
66
|
+
* >>> df
|
|
67
|
+
* shape: (2, 1)
|
|
68
|
+
* ┌───────────┐
|
|
69
|
+
* │ a │
|
|
70
|
+
* ├───────────┤
|
|
71
|
+
* │ [1, 2, 3] │
|
|
72
|
+
* │ [4, 5] │
|
|
73
|
+
* └───────────┘
|
|
74
|
+
* >>> df.withColumns($df.col("a").arr.any().alias("any_true"))
|
|
50
75
|
* shape: (2, 2)
|
|
51
|
-
*
|
|
52
|
-
* │ a
|
|
53
|
-
*
|
|
54
|
-
* │ [true,
|
|
55
|
-
* │ [
|
|
56
|
-
*
|
|
76
|
+
* ┌───────────────┬──────────┐
|
|
77
|
+
* │ a │ any_true │
|
|
78
|
+
* ├───────────────┼──────────┤
|
|
79
|
+
* │ [true, true] │ true │
|
|
80
|
+
* │ [true, false] │ true │
|
|
81
|
+
* └───────────────┴──────────┘
|
|
57
82
|
*/
|
|
58
83
|
any(): any;
|
|
59
84
|
/**
|
|
60
85
|
* Finds the index of the maximum value in each array.
|
|
61
86
|
* @returns ColumnExpression
|
|
62
87
|
* @example
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
89
|
+
* >>> df
|
|
90
|
+
* shape: (2, 1)
|
|
91
|
+
* ┌───────────┐
|
|
92
|
+
* │ a │
|
|
93
|
+
* ├───────────┤
|
|
94
|
+
* │ [1, 2, 3] │
|
|
95
|
+
* │ [4, 5] │
|
|
96
|
+
* └───────────┘
|
|
97
|
+
* >>> df.withColumns($df.col("a").arr.argMax().alias("max_idx"))
|
|
65
98
|
* shape: (2, 2)
|
|
66
99
|
* ┌───────────┬─────────┐
|
|
67
100
|
* │ a │ max_idx │
|
|
68
101
|
* ├───────────┼─────────┤
|
|
69
|
-
* │ [1,
|
|
70
|
-
* │ [
|
|
102
|
+
* │ [1, 2, 3] │ 2 │
|
|
103
|
+
* │ [4, 5] │ 1 │
|
|
71
104
|
* └───────────┴─────────┘
|
|
72
105
|
*/
|
|
73
|
-
|
|
106
|
+
argMax(): any;
|
|
74
107
|
/**
|
|
75
108
|
* Finds the index of the minimum value in each array.
|
|
76
109
|
* @returns ColumnExpression
|
|
77
110
|
* @example
|
|
78
|
-
|
|
79
|
-
|
|
111
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
112
|
+
* >>> df
|
|
113
|
+
* shape: (2, 1)
|
|
114
|
+
* ┌───────────┐
|
|
115
|
+
* │ a │
|
|
116
|
+
* ├───────────┤
|
|
117
|
+
* │ [1, 2, 3] │
|
|
118
|
+
* │ [4, 5] │
|
|
119
|
+
* └───────────┘
|
|
120
|
+
* >>> df.withColumns($df.col("a").arr.argMin().alias("min_idx"))
|
|
80
121
|
* shape: (2, 2)
|
|
81
122
|
* ┌───────────┬─────────┐
|
|
82
123
|
* │ a │ min_idx │
|
|
83
124
|
* ├───────────┼─────────┤
|
|
84
|
-
* │ [
|
|
85
|
-
* │ [
|
|
125
|
+
* │ [1, 2, 3] │ 0 │
|
|
126
|
+
* │ [4, 5] │ 0 │
|
|
86
127
|
* └───────────┴─────────┘
|
|
87
128
|
*/
|
|
88
|
-
|
|
129
|
+
argMin(): any;
|
|
89
130
|
/**
|
|
90
131
|
* Checks if nested lists contain item.
|
|
91
132
|
* @param item The element to search for.
|
|
92
133
|
* @returns ColumnExpression
|
|
93
134
|
* @example
|
|
94
|
-
|
|
95
|
-
|
|
135
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
136
|
+
* >>> df
|
|
137
|
+
* shape: (2, 1)
|
|
138
|
+
* ┌───────────┐
|
|
139
|
+
* │ a │
|
|
140
|
+
* ├───────────┤
|
|
141
|
+
* │ [1, 2, 3] │
|
|
142
|
+
* │ [4, 5] │
|
|
143
|
+
* └───────────┘
|
|
144
|
+
* >>> df.withColumns($df.col("a").arr.contains(3).alias("has_three"))
|
|
96
145
|
* shape: (2, 2)
|
|
97
146
|
* ┌───────────┬───────────┐
|
|
98
147
|
* │ a │ has_three │
|
|
@@ -107,24 +156,40 @@ export declare class ArrayExprNamespace {
|
|
|
107
156
|
* @param items Array of elements that must all be present.
|
|
108
157
|
* @returns ColumnExpression
|
|
109
158
|
* @example
|
|
110
|
-
|
|
111
|
-
|
|
159
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
160
|
+
* >>> df
|
|
161
|
+
* shape: (2, 1)
|
|
162
|
+
* ┌───────────┐
|
|
163
|
+
* │ a │
|
|
164
|
+
* ├───────────┤
|
|
165
|
+
* │ [1, 2, 3] │
|
|
166
|
+
* │ [4, 5] │
|
|
167
|
+
* └───────────┘
|
|
168
|
+
* >>> df.withColumns($df.col("a").arr.containsAll([1, 2]).alias("has_all"))
|
|
112
169
|
* shape: (2, 2)
|
|
113
170
|
* ┌───────────┬─────────┐
|
|
114
171
|
* │ a │ has_all │
|
|
115
172
|
* ├───────────┼─────────┤
|
|
116
173
|
* │ [1, 2, 3] │ true │
|
|
117
|
-
* │ [
|
|
174
|
+
* │ [4, 5] │ false │
|
|
118
175
|
* └───────────┴─────────┘
|
|
119
176
|
*/
|
|
120
|
-
|
|
177
|
+
containsAll(items: ArrayLike<any>): any;
|
|
121
178
|
/**
|
|
122
179
|
* Checks if nested lists contain any element in items.
|
|
123
180
|
* @param items Array of elements where at least one must be present.
|
|
124
181
|
* @returns ColumnExpression
|
|
125
182
|
* @example
|
|
126
|
-
|
|
127
|
-
|
|
183
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
184
|
+
* >>> df
|
|
185
|
+
* shape: (2, 1)
|
|
186
|
+
* ┌───────────┐
|
|
187
|
+
* │ a │
|
|
188
|
+
* ├───────────┤
|
|
189
|
+
* │ [1, 2, 3] │
|
|
190
|
+
* │ [4, 5] │
|
|
191
|
+
* └───────────┘
|
|
192
|
+
* >>> df.withColumns($df.col("a").arr.containsAny([2, 3]).alias("has_any"))
|
|
128
193
|
* shape: (2, 2)
|
|
129
194
|
* ┌────────┬─────────┐
|
|
130
195
|
* │ a │ has_any │
|
|
@@ -133,38 +198,54 @@ export declare class ArrayExprNamespace {
|
|
|
133
198
|
* │ [3, 4] │ true │
|
|
134
199
|
* └────────┴─────────┘
|
|
135
200
|
*/
|
|
136
|
-
|
|
201
|
+
containsAny(items: ArrayLike<any>): any;
|
|
137
202
|
/**
|
|
138
203
|
* Counts occurrence frequency of item inside nested lists.
|
|
139
204
|
* @param item The value to count occurrences of.
|
|
140
205
|
* @param options Statistics and matching options.
|
|
141
206
|
* @returns ColumnExpression
|
|
142
207
|
* @example
|
|
143
|
-
|
|
144
|
-
|
|
208
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
209
|
+
* >>> df
|
|
210
|
+
* shape: (2, 1)
|
|
211
|
+
* ┌───────────┐
|
|
212
|
+
* │ a │
|
|
213
|
+
* ├───────────┤
|
|
214
|
+
* │ [1, 2, 3] │
|
|
215
|
+
* │ [4, 5] │
|
|
216
|
+
* └───────────┘
|
|
217
|
+
* >>> df.withColumns($df.col("a").arr.countMatches(2).alias("twos"))
|
|
145
218
|
* shape: (2, 2)
|
|
146
|
-
*
|
|
147
|
-
* │ a
|
|
148
|
-
*
|
|
149
|
-
* │ [1, 2,
|
|
150
|
-
* │ [4, 5]
|
|
151
|
-
*
|
|
219
|
+
* ┌───────────┬──────┐
|
|
220
|
+
* │ a │ twos │
|
|
221
|
+
* ├───────────┼──────┤
|
|
222
|
+
* │ [1, 2, 3] │ 1 │
|
|
223
|
+
* │ [4, 5] │ 0 │
|
|
224
|
+
* └───────────┴──────┘
|
|
152
225
|
*/
|
|
153
|
-
|
|
226
|
+
countMatches(item: any, options?: UniqueArrayStatsOptions): any;
|
|
154
227
|
/**
|
|
155
228
|
* Filters elements of list columns matching a boolean sub-expression.
|
|
156
229
|
* @param expr The boolean column expression to filter by.
|
|
157
230
|
* @returns ColumnExpression
|
|
158
231
|
* @example
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
232
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
233
|
+
* >>> df
|
|
234
|
+
* shape: (2, 1)
|
|
235
|
+
* ┌───────────┐
|
|
236
|
+
* │ a │
|
|
237
|
+
* ├───────────┤
|
|
238
|
+
* │ [1, 2, 3] │
|
|
239
|
+
* │ [4, 5] │
|
|
240
|
+
* └───────────┘
|
|
241
|
+
* >>> df.withColumns($df.col("a").arr.filter($df.element().gt(2)).alias("filtered"))
|
|
242
|
+
* shape: (2, 2)
|
|
243
|
+
* ┌───────────┬──────────┐
|
|
244
|
+
* │ a │ filtered │
|
|
245
|
+
* ├───────────┼──────────┤
|
|
246
|
+
* │ [1, 2, 3] │ [3] │
|
|
247
|
+
* │ [4, 5] │ [4, 5] │
|
|
248
|
+
* └───────────┴──────────┘
|
|
168
249
|
*/
|
|
169
250
|
filter(expr: IExpr): any;
|
|
170
251
|
/**
|
|
@@ -172,117 +253,172 @@ export declare class ArrayExprNamespace {
|
|
|
172
253
|
* @param options Config options including handling of empty arrays and nulls.
|
|
173
254
|
* @returns ColumnExpression
|
|
174
255
|
* @example
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
*
|
|
256
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
257
|
+
* >>> df
|
|
258
|
+
* shape: (2, 1)
|
|
259
|
+
* ┌───────────┐
|
|
260
|
+
* │ a │
|
|
261
|
+
* ├───────────┤
|
|
262
|
+
* │ [1, 2, 3] │
|
|
263
|
+
* │ [4, 5] │
|
|
264
|
+
* └───────────┘
|
|
265
|
+
* >>> df.select([$df.col("group"), $df.col("values").arr.explode()])
|
|
266
|
+
* shape: (2, 2)
|
|
267
|
+
* ┌───────┬────────┐
|
|
268
|
+
* │ group │ values │
|
|
269
|
+
* ├───────┼────────┤
|
|
270
|
+
* │ A │ 1 │
|
|
271
|
+
* │ A │ 2 │
|
|
272
|
+
* └───────┴────────┘
|
|
185
273
|
*/
|
|
186
|
-
explode({
|
|
274
|
+
explode({ emptyAsNull, keepNulls }?: ExplodeOptions): any;
|
|
187
275
|
/**
|
|
188
276
|
* Returns the first element of each list.
|
|
189
|
-
* @param
|
|
277
|
+
* @param nullOnOob If true, returns null if the list is empty (default: true).
|
|
190
278
|
* @returns ColumnExpression
|
|
191
279
|
* @example
|
|
192
|
-
|
|
193
|
-
|
|
280
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
281
|
+
* >>> df
|
|
282
|
+
* shape: (2, 1)
|
|
283
|
+
* ┌───────────┐
|
|
284
|
+
* │ a │
|
|
285
|
+
* ├───────────┤
|
|
286
|
+
* │ [1, 2, 3] │
|
|
287
|
+
* │ [4, 5] │
|
|
288
|
+
* └───────────┘
|
|
289
|
+
* >>> df.withColumns($df.col("a").arr.first().alias("first_a"))
|
|
194
290
|
* shape: (2, 2)
|
|
195
|
-
*
|
|
196
|
-
* │ a
|
|
197
|
-
*
|
|
198
|
-
* │ [
|
|
199
|
-
* │ [
|
|
200
|
-
*
|
|
291
|
+
* ┌───────────┬─────────┐
|
|
292
|
+
* │ a │ first_a │
|
|
293
|
+
* ├───────────┼─────────┤
|
|
294
|
+
* │ [1, 2, 3] │ 1 │
|
|
295
|
+
* │ [4, 5] │ 4 │
|
|
296
|
+
* └───────────┴─────────┘
|
|
201
297
|
*/
|
|
202
|
-
first(
|
|
298
|
+
first(nullOnOob?: boolean): any;
|
|
203
299
|
/**
|
|
204
300
|
* Gathers specific indices from each nested list.
|
|
205
301
|
* @param indices Index or array of indices to extract.
|
|
206
|
-
* @param
|
|
302
|
+
* @param nullOnOob If true, returns null for indices out of bounds (default: true).
|
|
207
303
|
* @returns ColumnExpression
|
|
208
304
|
* @example
|
|
209
|
-
|
|
210
|
-
|
|
305
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
306
|
+
* >>> df
|
|
307
|
+
* shape: (2, 1)
|
|
308
|
+
* ┌───────────┐
|
|
309
|
+
* │ a │
|
|
310
|
+
* ├───────────┤
|
|
311
|
+
* │ [1, 2, 3] │
|
|
312
|
+
* │ [4, 5] │
|
|
313
|
+
* └───────────┘
|
|
314
|
+
* >>> df.withColumns($df.col("a").arr.gather([0, 2]).alias("g"))
|
|
211
315
|
* shape: (2, 2)
|
|
212
|
-
*
|
|
213
|
-
* │ a
|
|
214
|
-
*
|
|
215
|
-
* │ [
|
|
216
|
-
* │ [
|
|
217
|
-
*
|
|
316
|
+
* ┌───────────┬──────────┐
|
|
317
|
+
* │ a │ g │
|
|
318
|
+
* ├───────────┼──────────┤
|
|
319
|
+
* │ [1, 2, 3] │ [1, 3] │
|
|
320
|
+
* │ [4, 5] │ [4, null]│
|
|
321
|
+
* └───────────┴──────────┘
|
|
218
322
|
*/
|
|
219
|
-
gather(indices: number | ArrayLike<number>,
|
|
323
|
+
gather(indices: number | ArrayLike<number>, nullOnOob?: boolean): any;
|
|
220
324
|
/**
|
|
221
325
|
* Gather element slices with custom steps.
|
|
222
326
|
* @param options Config options including offset, limit, and step size.
|
|
223
327
|
* @returns ColumnExpression
|
|
224
328
|
* @example
|
|
225
|
-
|
|
226
|
-
|
|
329
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
330
|
+
* >>> df
|
|
331
|
+
* shape: (2, 1)
|
|
332
|
+
* ┌───────────┐
|
|
333
|
+
* │ a │
|
|
334
|
+
* ├───────────┤
|
|
335
|
+
* │ [1, 2, 3] │
|
|
336
|
+
* │ [4, 5] │
|
|
337
|
+
* └───────────┘
|
|
338
|
+
* >>> df.withColumns($df.col("a").arr.gatherEvery({ step: 2 }).alias("ge"))
|
|
227
339
|
* shape: (2, 2)
|
|
228
|
-
*
|
|
229
|
-
* │ a
|
|
230
|
-
*
|
|
231
|
-
* │ [1, 2, 3
|
|
232
|
-
* │ [
|
|
233
|
-
*
|
|
340
|
+
* ┌───────────┬────────┐
|
|
341
|
+
* │ a │ ge │
|
|
342
|
+
* ├───────────┼────────┤
|
|
343
|
+
* │ [1, 2, 3] │ [1, 3] │
|
|
344
|
+
* │ [4, 5] │ [4] │
|
|
345
|
+
* └───────────┴────────┘
|
|
234
346
|
*/
|
|
235
|
-
|
|
347
|
+
gatherEvery(options?: StepSliceArrayOptions): any;
|
|
236
348
|
/**
|
|
237
349
|
* Extracts a single list element by its index position.
|
|
238
350
|
* @param index The 0-based or negative index position to extract.
|
|
239
|
-
* @param
|
|
351
|
+
* @param nullOnOob If true, returns null if index is out of bounds (default: true).
|
|
240
352
|
* @returns ColumnExpression
|
|
241
353
|
* @example
|
|
242
|
-
|
|
243
|
-
|
|
354
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
355
|
+
* >>> df
|
|
356
|
+
* shape: (2, 1)
|
|
357
|
+
* ┌───────────┐
|
|
358
|
+
* │ a │
|
|
359
|
+
* ├───────────┤
|
|
360
|
+
* │ [1, 2, 3] │
|
|
361
|
+
* │ [4, 5] │
|
|
362
|
+
* └───────────┘
|
|
363
|
+
* >>> df.withColumns($df.col("a").arr.get(1).alias("second"))
|
|
244
364
|
* shape: (2, 2)
|
|
245
|
-
*
|
|
246
|
-
* │ a
|
|
247
|
-
*
|
|
248
|
-
* │ [
|
|
249
|
-
* │ [
|
|
250
|
-
*
|
|
365
|
+
* ┌───────────┬────────┐
|
|
366
|
+
* │ a │ second │
|
|
367
|
+
* ├───────────┼────────┤
|
|
368
|
+
* │ [1, 2, 3] │ 2 │
|
|
369
|
+
* │ [4, 5] │ 5 │
|
|
370
|
+
* └───────────┴────────┘
|
|
251
371
|
*/
|
|
252
|
-
get(index: number,
|
|
372
|
+
get(index: number, nullOnOob?: boolean): any;
|
|
253
373
|
/**
|
|
254
374
|
* Joins elements of list columns into a single string column.
|
|
255
375
|
* @param separator The character sequence separating list elements.
|
|
256
376
|
* @param options String conversion options.
|
|
257
377
|
* @returns ColumnExpression
|
|
258
378
|
* @example
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
379
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
380
|
+
* >>> df
|
|
381
|
+
* shape: (2, 1)
|
|
382
|
+
* ┌───────────┐
|
|
383
|
+
* │ a │
|
|
384
|
+
* ├───────────┤
|
|
385
|
+
* │ [1, 2, 3] │
|
|
386
|
+
* │ [4, 5] │
|
|
387
|
+
* └───────────┘
|
|
388
|
+
* >>> df.withColumns($df.col("a").arr.join("-").alias("joined"))
|
|
389
|
+
* shape: (2, 2)
|
|
390
|
+
* ┌────────────┬────────┐
|
|
391
|
+
* │ a │ joined │
|
|
392
|
+
* ├────────────┼────────┤
|
|
393
|
+
* │ ["a", "b"] │ "a-b" │
|
|
394
|
+
* │ ["c"] │ "c" │
|
|
395
|
+
* └────────────┴────────┘
|
|
268
396
|
*/
|
|
269
397
|
join(separator?: string, options?: JoinArrayOptions): any;
|
|
270
398
|
/**
|
|
271
399
|
* Returns the last element of each list.
|
|
272
|
-
* @param
|
|
400
|
+
* @param nullOnOob If true, returns null if the list is empty (default: true).
|
|
273
401
|
* @returns ColumnExpression
|
|
274
402
|
* @example
|
|
275
|
-
|
|
276
|
-
|
|
403
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
404
|
+
* >>> df
|
|
405
|
+
* shape: (2, 1)
|
|
406
|
+
* ┌───────────┐
|
|
407
|
+
* │ a │
|
|
408
|
+
* ├───────────┤
|
|
409
|
+
* │ [1, 2, 3] │
|
|
410
|
+
* │ [4, 5] │
|
|
411
|
+
* └───────────┘
|
|
412
|
+
* >>> df.withColumns($df.col("a").arr.last().alias("last_a"))
|
|
277
413
|
* shape: (2, 2)
|
|
278
|
-
*
|
|
279
|
-
* │ a
|
|
280
|
-
*
|
|
281
|
-
* │ [
|
|
282
|
-
* │ [
|
|
283
|
-
*
|
|
414
|
+
* ┌───────────┬────────┐
|
|
415
|
+
* │ a │ last_a │
|
|
416
|
+
* ├───────────┼────────┤
|
|
417
|
+
* │ [1, 2, 3] │ 3 │
|
|
418
|
+
* │ [4, 5] │ 5 │
|
|
419
|
+
* └───────────┴────────┘
|
|
284
420
|
*/
|
|
285
|
-
last(
|
|
421
|
+
last(nullOnOob?: boolean): any;
|
|
286
422
|
/**
|
|
287
423
|
* Returns the length of each list inside the column cell.
|
|
288
424
|
*/
|
|
@@ -291,29 +427,45 @@ export declare class ArrayExprNamespace {
|
|
|
291
427
|
* Returns the length of each list inside the column cell.
|
|
292
428
|
* @returns ColumnExpression
|
|
293
429
|
* @example
|
|
294
|
-
|
|
295
|
-
|
|
430
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
431
|
+
* >>> df
|
|
432
|
+
* shape: (2, 1)
|
|
433
|
+
* ┌───────────┐
|
|
434
|
+
* │ a │
|
|
435
|
+
* ├───────────┤
|
|
436
|
+
* │ [1, 2, 3] │
|
|
437
|
+
* │ [4, 5] │
|
|
438
|
+
* └───────────┘
|
|
439
|
+
* >>> df.withColumns($df.col("a").arr.lengths().alias("len_a"))
|
|
296
440
|
* shape: (2, 2)
|
|
297
|
-
*
|
|
298
|
-
* │ a
|
|
299
|
-
*
|
|
300
|
-
* │ [
|
|
301
|
-
* │ [
|
|
302
|
-
*
|
|
441
|
+
* ┌───────────┬───────┐
|
|
442
|
+
* │ a │ len_a │
|
|
443
|
+
* ├───────────┼───────┤
|
|
444
|
+
* │ [1, 2, 3] │ 3 │
|
|
445
|
+
* │ [4, 5] │ 2 │
|
|
446
|
+
* └───────────┴───────┘
|
|
303
447
|
*/
|
|
304
448
|
lengths(): any;
|
|
305
449
|
/**
|
|
306
450
|
* Returns the maximum value of elements inside each list.
|
|
307
451
|
* @returns ColumnExpression
|
|
308
452
|
* @example
|
|
309
|
-
|
|
310
|
-
|
|
453
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
454
|
+
* >>> df
|
|
455
|
+
* shape: (2, 1)
|
|
456
|
+
* ┌───────────┐
|
|
457
|
+
* │ a │
|
|
458
|
+
* ├───────────┤
|
|
459
|
+
* │ [1, 2, 3] │
|
|
460
|
+
* │ [4, 5] │
|
|
461
|
+
* └───────────┘
|
|
462
|
+
* >>> df.withColumns($df.col("a").arr.max().alias("max_a"))
|
|
311
463
|
* shape: (2, 2)
|
|
312
464
|
* ┌───────────┬───────┐
|
|
313
465
|
* │ a │ max_a │
|
|
314
466
|
* ├───────────┼───────┤
|
|
315
|
-
* │ [1,
|
|
316
|
-
* │ [
|
|
467
|
+
* │ [1, 2, 3] │ 3 │
|
|
468
|
+
* │ [4, 5] │ 5 │
|
|
317
469
|
* └───────────┴───────┘
|
|
318
470
|
*/
|
|
319
471
|
max(): any;
|
|
@@ -321,14 +473,22 @@ export declare class ArrayExprNamespace {
|
|
|
321
473
|
* Returns average of elements inside each list.
|
|
322
474
|
* @returns ColumnExpression
|
|
323
475
|
* @example
|
|
324
|
-
|
|
325
|
-
|
|
476
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
477
|
+
* >>> df
|
|
478
|
+
* shape: (2, 1)
|
|
479
|
+
* ┌───────────┐
|
|
480
|
+
* │ a │
|
|
481
|
+
* ├───────────┤
|
|
482
|
+
* │ [1, 2, 3] │
|
|
483
|
+
* │ [4, 5] │
|
|
484
|
+
* └───────────┘
|
|
485
|
+
* >>> df.withColumns($df.col("a").arr.mean().alias("mean_a"))
|
|
326
486
|
* shape: (2, 2)
|
|
327
487
|
* ┌───────────┬────────┐
|
|
328
488
|
* │ a │ mean_a │
|
|
329
489
|
* ├───────────┼────────┤
|
|
330
|
-
* │ [1,
|
|
331
|
-
* │ [
|
|
490
|
+
* │ [1, 2, 3] │ 2 │
|
|
491
|
+
* │ [4, 5] │ 4.5 │
|
|
332
492
|
* └───────────┴────────┘
|
|
333
493
|
*/
|
|
334
494
|
mean(): any;
|
|
@@ -336,29 +496,45 @@ export declare class ArrayExprNamespace {
|
|
|
336
496
|
* Returns statistical median inside each list.
|
|
337
497
|
* @returns ColumnExpression
|
|
338
498
|
* @example
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
499
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
500
|
+
* >>> df
|
|
501
|
+
* shape: (2, 1)
|
|
502
|
+
* ┌───────────┐
|
|
503
|
+
* │ a │
|
|
504
|
+
* ├───────────┤
|
|
505
|
+
* │ [1, 2, 3] │
|
|
506
|
+
* │ [4, 5] │
|
|
507
|
+
* └───────────┘
|
|
508
|
+
* >>> df.withColumns($df.col("a").arr.median().alias("med"))
|
|
509
|
+
* shape: (2, 2)
|
|
510
|
+
* ┌───────────┬──────┐
|
|
511
|
+
* │ a │ med │
|
|
512
|
+
* ├───────────┼──────┤
|
|
513
|
+
* │ [1, 2, 3] │ 2 │
|
|
514
|
+
* │ [4, 5] │ 4.5 │
|
|
515
|
+
* └───────────┴──────┘
|
|
348
516
|
*/
|
|
349
517
|
median(): any;
|
|
350
518
|
/**
|
|
351
519
|
* Returns minimum of elements inside each list.
|
|
352
520
|
* @returns ColumnExpression
|
|
353
521
|
* @example
|
|
354
|
-
|
|
355
|
-
|
|
522
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
523
|
+
* >>> df
|
|
524
|
+
* shape: (2, 1)
|
|
525
|
+
* ┌───────────┐
|
|
526
|
+
* │ a │
|
|
527
|
+
* ├───────────┤
|
|
528
|
+
* │ [1, 2, 3] │
|
|
529
|
+
* │ [4, 5] │
|
|
530
|
+
* └───────────┘
|
|
531
|
+
* >>> df.withColumns($df.col("a").arr.min().alias("min_a"))
|
|
356
532
|
* shape: (2, 2)
|
|
357
533
|
* ┌───────────┬───────┐
|
|
358
534
|
* │ a │ min_a │
|
|
359
535
|
* ├───────────┼───────┤
|
|
360
|
-
* │ [1,
|
|
361
|
-
* │ [
|
|
536
|
+
* │ [1, 2, 3] │ 1 │
|
|
537
|
+
* │ [4, 5] │ 4 │
|
|
362
538
|
* └───────────┴───────┘
|
|
363
539
|
*/
|
|
364
540
|
min(): any;
|
|
@@ -366,15 +542,23 @@ export declare class ArrayExprNamespace {
|
|
|
366
542
|
* Returns the mode value inside each list.
|
|
367
543
|
* @returns ColumnExpression
|
|
368
544
|
* @example
|
|
369
|
-
|
|
370
|
-
|
|
545
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
546
|
+
* >>> df
|
|
547
|
+
* shape: (2, 1)
|
|
548
|
+
* ┌───────────┐
|
|
549
|
+
* │ a │
|
|
550
|
+
* ├───────────┤
|
|
551
|
+
* │ [1, 2, 3] │
|
|
552
|
+
* │ [4, 5] │
|
|
553
|
+
* └───────────┘
|
|
554
|
+
* >>> df.withColumns($df.col("a").arr.mode().alias("mode_a"))
|
|
371
555
|
* shape: (2, 2)
|
|
372
|
-
*
|
|
373
|
-
* │ a
|
|
374
|
-
*
|
|
375
|
-
* │ [1, 2, 2, 3] │
|
|
376
|
-
* │ [
|
|
377
|
-
*
|
|
556
|
+
* ┌───────────┬───────────┐
|
|
557
|
+
* │ a │ mode_a │
|
|
558
|
+
* ├───────────┼───────────┤
|
|
559
|
+
* │ [1, 2, 3] │ [1, 2, 3] │
|
|
560
|
+
* │ [4, 5] │ [4, 5] │
|
|
561
|
+
* └───────────┴───────────┘
|
|
378
562
|
*/
|
|
379
563
|
mode(): any;
|
|
380
564
|
/**
|
|
@@ -382,23 +566,39 @@ export declare class ArrayExprNamespace {
|
|
|
382
566
|
* @param options Formatting/statistics parameters.
|
|
383
567
|
* @returns ColumnExpression
|
|
384
568
|
* @example
|
|
385
|
-
|
|
386
|
-
|
|
569
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
570
|
+
* >>> df
|
|
571
|
+
* shape: (2, 1)
|
|
572
|
+
* ┌───────────┐
|
|
573
|
+
* │ a │
|
|
574
|
+
* ├───────────┤
|
|
575
|
+
* │ [1, 2, 3] │
|
|
576
|
+
* │ [4, 5] │
|
|
577
|
+
* └───────────┘
|
|
578
|
+
* >>> df.withColumns($df.col("a").arr.nUnique().alias("unique_len"))
|
|
387
579
|
* shape: (2, 2)
|
|
388
|
-
*
|
|
389
|
-
* │ a
|
|
390
|
-
*
|
|
391
|
-
* │ [1, 2,
|
|
392
|
-
* │ [4, 5]
|
|
393
|
-
*
|
|
580
|
+
* ┌───────────┬────────────┐
|
|
581
|
+
* │ a │ unique_len │
|
|
582
|
+
* ├───────────┼────────────┤
|
|
583
|
+
* │ [1, 2, 3] │ 3 │
|
|
584
|
+
* │ [4, 5] │ 2 │
|
|
585
|
+
* └───────────┴────────────┘
|
|
394
586
|
*/
|
|
395
|
-
|
|
587
|
+
nUnique(options?: UniqueArrayStatsOptions): any;
|
|
396
588
|
/**
|
|
397
589
|
* Reverses elements of list columns.
|
|
398
590
|
* @returns ColumnExpression
|
|
399
591
|
* @example
|
|
400
|
-
|
|
401
|
-
|
|
592
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
593
|
+
* >>> df
|
|
594
|
+
* shape: (2, 1)
|
|
595
|
+
* ┌───────────┐
|
|
596
|
+
* │ a │
|
|
597
|
+
* ├───────────┤
|
|
598
|
+
* │ [1, 2, 3] │
|
|
599
|
+
* │ [4, 5] │
|
|
600
|
+
* └───────────┘
|
|
601
|
+
* >>> df.withColumns($df.col("a").arr.reverse().alias("reversed"))
|
|
402
602
|
* shape: (2, 2)
|
|
403
603
|
* ┌───────────┬───────────┐
|
|
404
604
|
* │ a │ reversed │
|
|
@@ -413,8 +613,16 @@ export declare class ArrayExprNamespace {
|
|
|
413
613
|
* @param n Positive or negative offsets shift amount (default: 1).
|
|
414
614
|
* @returns ColumnExpression
|
|
415
615
|
* @example
|
|
416
|
-
|
|
417
|
-
|
|
616
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
617
|
+
* >>> df
|
|
618
|
+
* shape: (2, 1)
|
|
619
|
+
* ┌───────────┐
|
|
620
|
+
* │ a │
|
|
621
|
+
* ├───────────┤
|
|
622
|
+
* │ [1, 2, 3] │
|
|
623
|
+
* │ [4, 5] │
|
|
624
|
+
* └───────────┘
|
|
625
|
+
* >>> df.withColumns($df.col("a").arr.shift(1).alias("shifted"))
|
|
418
626
|
* shape: (2, 2)
|
|
419
627
|
* ┌───────────┬──────────────────┐
|
|
420
628
|
* │ a │ shifted │
|
|
@@ -430,15 +638,23 @@ export declare class ArrayExprNamespace {
|
|
|
430
638
|
* @param end The slice ending index.
|
|
431
639
|
* @returns ColumnExpression
|
|
432
640
|
* @example
|
|
433
|
-
|
|
434
|
-
|
|
641
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
642
|
+
* >>> df
|
|
643
|
+
* shape: (2, 1)
|
|
644
|
+
* ┌───────────┐
|
|
645
|
+
* │ a │
|
|
646
|
+
* ├───────────┤
|
|
647
|
+
* │ [1, 2, 3] │
|
|
648
|
+
* │ [4, 5] │
|
|
649
|
+
* └───────────┘
|
|
650
|
+
* >>> df.withColumns($df.col("a").arr.slice(1, 3).alias("sliced"))
|
|
435
651
|
* shape: (2, 2)
|
|
436
|
-
*
|
|
437
|
-
* │ a
|
|
438
|
-
*
|
|
439
|
-
* │ [1, 2, 3
|
|
440
|
-
* │ [
|
|
441
|
-
*
|
|
652
|
+
* ┌───────────┬────────┐
|
|
653
|
+
* │ a │ sliced │
|
|
654
|
+
* ├───────────┼────────┤
|
|
655
|
+
* │ [1, 2, 3] │ [2, 3] │
|
|
656
|
+
* │ [4, 5] │ [5] │
|
|
657
|
+
* └───────────┴────────┘
|
|
442
658
|
*/
|
|
443
659
|
slice(start?: number, end?: number): any;
|
|
444
660
|
/**
|
|
@@ -448,8 +664,16 @@ export declare class ArrayExprNamespace {
|
|
|
448
664
|
* @param items The elements to insert.
|
|
449
665
|
* @returns ColumnExpression
|
|
450
666
|
* @example
|
|
451
|
-
|
|
452
|
-
|
|
667
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
668
|
+
* >>> df
|
|
669
|
+
* shape: (2, 1)
|
|
670
|
+
* ┌───────────┐
|
|
671
|
+
* │ a │
|
|
672
|
+
* ├───────────┤
|
|
673
|
+
* │ [1, 2, 3] │
|
|
674
|
+
* │ [4, 5] │
|
|
675
|
+
* └───────────┘
|
|
676
|
+
* >>> df.withColumns($df.col("a").arr.splice(1, 1, 10, 20).alias("spliced"))
|
|
453
677
|
* shape: (2, 2)
|
|
454
678
|
* ┌───────────┬─────────────────┐
|
|
455
679
|
* │ a │ spliced │
|
|
@@ -464,14 +688,22 @@ export declare class ArrayExprNamespace {
|
|
|
464
688
|
* @param options Sort customization parameters (e.g. descending flag).
|
|
465
689
|
* @returns ColumnExpression
|
|
466
690
|
* @example
|
|
467
|
-
|
|
468
|
-
|
|
691
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
692
|
+
* >>> df
|
|
693
|
+
* shape: (2, 1)
|
|
694
|
+
* ┌───────────┐
|
|
695
|
+
* │ a │
|
|
696
|
+
* ├───────────┤
|
|
697
|
+
* │ [1, 2, 3] │
|
|
698
|
+
* │ [4, 5] │
|
|
699
|
+
* └───────────┘
|
|
700
|
+
* >>> df.withColumns($df.col("a").arr.sort().alias("sorted"))
|
|
469
701
|
* shape: (2, 2)
|
|
470
702
|
* ┌───────────┬───────────┐
|
|
471
703
|
* │ a │ sorted │
|
|
472
704
|
* ├───────────┼───────────┤
|
|
473
|
-
* │ [
|
|
474
|
-
* │ [
|
|
705
|
+
* │ [1, 2, 3] │ [1, 2, 3] │
|
|
706
|
+
* │ [4, 5] │ [4, 5] │
|
|
475
707
|
* └───────────┴───────────┘
|
|
476
708
|
*/
|
|
477
709
|
sort(options?: SortArrayOptions): any;
|
|
@@ -479,29 +711,45 @@ export declare class ArrayExprNamespace {
|
|
|
479
711
|
* Returns sample standard deviation of elements inside each list.
|
|
480
712
|
* @returns ColumnExpression
|
|
481
713
|
* @example
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
714
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
715
|
+
* >>> df
|
|
716
|
+
* shape: (2, 1)
|
|
717
|
+
* ┌───────────┐
|
|
718
|
+
* │ a │
|
|
719
|
+
* ├───────────┤
|
|
720
|
+
* │ [1, 2, 3] │
|
|
721
|
+
* │ [4, 5] │
|
|
722
|
+
* └───────────┘
|
|
723
|
+
* >>> df.withColumns($df.col("a").arr.std().alias("std_dev"))
|
|
724
|
+
* shape: (2, 2)
|
|
725
|
+
* ┌───────────┬──────────┐
|
|
726
|
+
* │ a │ std_dev │
|
|
727
|
+
* ├───────────┼──────────┤
|
|
728
|
+
* │ [1, 2, 3] │ 1 │
|
|
729
|
+
* │ [4, 5] │ 0.707107 │
|
|
730
|
+
* └───────────┴──────────┘
|
|
491
731
|
*/
|
|
492
732
|
std(): any;
|
|
493
733
|
/**
|
|
494
734
|
* Returns sum of elements inside each list.
|
|
495
735
|
* @returns ColumnExpression
|
|
496
736
|
* @example
|
|
497
|
-
|
|
498
|
-
|
|
737
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
738
|
+
* >>> df
|
|
739
|
+
* shape: (2, 1)
|
|
740
|
+
* ┌───────────┐
|
|
741
|
+
* │ a │
|
|
742
|
+
* ├───────────┤
|
|
743
|
+
* │ [1, 2, 3] │
|
|
744
|
+
* │ [4, 5] │
|
|
745
|
+
* └───────────┘
|
|
746
|
+
* >>> df.withColumns($df.col("a").arr.sum().alias("sum_a"))
|
|
499
747
|
* shape: (2, 2)
|
|
500
748
|
* ┌───────────┬───────┐
|
|
501
749
|
* │ a │ sum_a │
|
|
502
750
|
* ├───────────┼───────┤
|
|
503
751
|
* │ [1, 2, 3] │ 6 │
|
|
504
|
-
* │ [
|
|
752
|
+
* │ [4, 5] │ 9 │
|
|
505
753
|
* └───────────┴───────┘
|
|
506
754
|
*/
|
|
507
755
|
sum(): any;
|
|
@@ -510,8 +758,16 @@ export declare class ArrayExprNamespace {
|
|
|
510
758
|
* @param options Config flags including custom field names or upper bound size.
|
|
511
759
|
* @returns ColumnExpression
|
|
512
760
|
* @example
|
|
513
|
-
|
|
514
|
-
|
|
761
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
762
|
+
* >>> df
|
|
763
|
+
* shape: (2, 1)
|
|
764
|
+
* ┌───────────┐
|
|
765
|
+
* │ a │
|
|
766
|
+
* ├───────────┤
|
|
767
|
+
* │ [1, 2, 3] │
|
|
768
|
+
* │ [4, 5] │
|
|
769
|
+
* └───────────┘
|
|
770
|
+
* >>> df.withColumns($df.col("a").arr.toStruct({ fields: ["x", "y"] }).alias("struct_a"))
|
|
515
771
|
* shape: (2, 2)
|
|
516
772
|
* ┌────────┬────────────────┐
|
|
517
773
|
* │ a │ struct_a │
|
|
@@ -520,35 +776,51 @@ export declare class ArrayExprNamespace {
|
|
|
520
776
|
* │ [3, 4] │ { x: 3, y: 4 } │
|
|
521
777
|
* └────────┴────────────────┘
|
|
522
778
|
*/
|
|
523
|
-
|
|
779
|
+
toStruct({ upperBound, fields }?: ToStructOptions): any;
|
|
524
780
|
/**
|
|
525
781
|
* Fills each list with unique elements only.
|
|
526
782
|
* @param options Custom uniqueness matching configuration.
|
|
527
783
|
* @returns ColumnExpression
|
|
528
784
|
* @example
|
|
529
|
-
|
|
530
|
-
|
|
785
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
786
|
+
* >>> df
|
|
787
|
+
* shape: (2, 1)
|
|
788
|
+
* ┌───────────┐
|
|
789
|
+
* │ a │
|
|
790
|
+
* ├───────────┤
|
|
791
|
+
* │ [1, 2, 3] │
|
|
792
|
+
* │ [4, 5] │
|
|
793
|
+
* └───────────┘
|
|
794
|
+
* >>> df.withColumns($df.col("a").arr.unique().alias("unique_a"))
|
|
531
795
|
* shape: (2, 2)
|
|
532
|
-
*
|
|
533
|
-
* │ a
|
|
534
|
-
*
|
|
535
|
-
* │ [1, 2,
|
|
536
|
-
* │ [4,
|
|
537
|
-
*
|
|
796
|
+
* ┌───────────┬───────────┐
|
|
797
|
+
* │ a │ unique_a │
|
|
798
|
+
* ├───────────┼───────────┤
|
|
799
|
+
* │ [1, 2, 3] │ [1, 2, 3] │
|
|
800
|
+
* │ [4, 5] │ [4, 5] │
|
|
801
|
+
* └───────────┴───────────┘
|
|
538
802
|
*/
|
|
539
803
|
unique(options?: UniqueArrayStatsOptions): any;
|
|
540
804
|
/**
|
|
541
805
|
* Returns sample variance of elements inside each list.
|
|
542
806
|
* @returns ColumnExpression
|
|
543
807
|
* @example
|
|
544
|
-
|
|
545
|
-
|
|
808
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
809
|
+
* >>> df
|
|
810
|
+
* shape: (2, 1)
|
|
811
|
+
* ┌───────────┐
|
|
812
|
+
* │ a │
|
|
813
|
+
* ├───────────┤
|
|
814
|
+
* │ [1, 2, 3] │
|
|
815
|
+
* │ [4, 5] │
|
|
816
|
+
* └───────────┘
|
|
817
|
+
* >>> df.withColumns($df.col("a").arr.variance().alias("var_a"))
|
|
546
818
|
* shape: (2, 2)
|
|
547
819
|
* ┌───────────┬───────┐
|
|
548
820
|
* │ a │ var_a │
|
|
549
821
|
* ├───────────┼───────┤
|
|
550
822
|
* │ [1, 2, 3] │ 1 │
|
|
551
|
-
* │ [
|
|
823
|
+
* │ [4, 5] │ 0.5 │
|
|
552
824
|
* └───────────┴───────┘
|
|
553
825
|
*/
|
|
554
826
|
variance(): any;
|
|
@@ -557,8 +829,16 @@ export declare class ArrayExprNamespace {
|
|
|
557
829
|
* @param expr The sub-expression to evaluate inside each nested list.
|
|
558
830
|
* @returns ColumnExpression
|
|
559
831
|
* @example
|
|
560
|
-
|
|
561
|
-
|
|
832
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
833
|
+
* >>> df
|
|
834
|
+
* shape: (2, 1)
|
|
835
|
+
* ┌───────────┐
|
|
836
|
+
* │ a │
|
|
837
|
+
* ├───────────┤
|
|
838
|
+
* │ [1, 2, 3] │
|
|
839
|
+
* │ [4, 5] │
|
|
840
|
+
* └───────────┘
|
|
841
|
+
* >>> df.withColumns($df.col("a").arr.eval($df.element().mul(10)).alias("multiplied"))
|
|
562
842
|
* shape: (2, 2)
|
|
563
843
|
* ┌────────┬────────────┐
|
|
564
844
|
* │ a │ multiplied │
|
|
@@ -577,7 +857,23 @@ export declare class ArrayExpr extends ExprBase {
|
|
|
577
857
|
* @syntax $df.col(<column_name>).arr
|
|
578
858
|
* @returns ArrayExprNamespace
|
|
579
859
|
* @example
|
|
860
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
861
|
+
* >>> df
|
|
862
|
+
* shape: (2, 1)
|
|
863
|
+
* ┌───────────┐
|
|
864
|
+
* │ a │
|
|
865
|
+
* ├───────────┤
|
|
866
|
+
* │ [1, 2, 3] │
|
|
867
|
+
* │ [4, 5] │
|
|
868
|
+
* └───────────┘
|
|
580
869
|
* >>> df.select($df.col("a").arr.len())
|
|
870
|
+
* shape: (2, 1)
|
|
871
|
+
* ┌─────┐
|
|
872
|
+
* │ len │
|
|
873
|
+
* ├─────┤
|
|
874
|
+
* │ 3 │
|
|
875
|
+
* │ 2 │
|
|
876
|
+
* └─────┘
|
|
581
877
|
*/
|
|
582
878
|
get arr(): ArrayExprNamespace;
|
|
583
879
|
}
|