df-script 1.6.0 → 1.7.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 +1 -1
- package/dist/api.d.ts +2 -1
- package/dist/assets/index-DBhGK6Tp.css +1 -0
- package/dist/assets/index-DEJEV_tU.js +195 -0
- package/dist/columnExpressions/ColumnExpr.d.ts +12 -5
- package/dist/columnExpressions/ExprBase.d.ts +26 -12
- package/dist/columnExpressions/constants.d.ts +1 -0
- package/dist/columnExpressions/functions/all.d.ts +23 -0
- package/dist/columnExpressions/functions/coalesce.d.ts +29 -0
- package/dist/columnExpressions/functions/element.d.ts +25 -0
- package/dist/columnExpressions/functions/exclude.d.ts +24 -0
- package/dist/columnExpressions/functions/implode.d.ts +28 -0
- package/dist/columnExpressions/functions/lit.d.ts +27 -0
- package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
- package/dist/columnExpressions/functions/struct.d.ts +31 -0
- package/dist/columnExpressions/functions/when.d.ts +36 -6
- package/dist/columnExpressions/index.d.ts +1 -0
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +334 -0
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +609 -0
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +533 -5
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +656 -3
- package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +530 -4
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
- package/dist/columnExpressions/types.d.ts +1 -0
- package/dist/dataframe/dataframe.d.ts +932 -2
- package/dist/dataframe/grouped/grouped.d.ts +41 -6
- package/dist/dataframe/types.d.ts +1 -0
- package/dist/dataframe/utils.d.ts +1 -0
- package/dist/datatypes/types.d.ts +45 -0
- package/dist/exceptions/index.d.ts +23 -0
- package/dist/functions/concat.d.ts +50 -0
- package/dist/functions/read_csv.d.ts +9 -0
- package/dist/functions/read_json.d.ts +7 -2
- package/dist/index.html +17 -0
- package/dist/index.js +5 -5
- package/dist/index.mjs +6 -0
- package/dist/types.d.ts +47 -14
- package/dist/utils/array.d.ts +32 -1
- package/dist/utils/csv.d.ts +1 -0
- package/dist/utils/date.d.ts +10 -27
- package/dist/utils/json.d.ts +1 -0
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/string.d.ts +12 -0
- package/package.json +18 -4
- package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
- package/dist/utils/guards.d.ts +0 -13
- package/dist/utils/list.d.ts +0 -217
|
@@ -1,39 +1,567 @@
|
|
|
1
1
|
import { ExprBase } from "../ExprBase";
|
|
2
2
|
import { SortArrayOptions, StepSliceArrayOptions } from "../../utils";
|
|
3
|
-
import type { UniqueArrayStatsOptions, JoinArrayOptions, ExplodeOptions, IExpr } from "../../types";
|
|
3
|
+
import type { UniqueArrayStatsOptions, JoinArrayOptions, ExplodeOptions, IExpr, AnyTypedArray, ToStructOptions } from "../../types";
|
|
4
|
+
/**
|
|
5
|
+
* @namespace $df.col.arr
|
|
6
|
+
* @category ColumnExpression
|
|
7
|
+
* @syntax $df.col(<column_name>).arr.{symbol}(...)
|
|
8
|
+
*/
|
|
4
9
|
export declare class ArrayExprNamespace {
|
|
5
10
|
expr: any;
|
|
6
11
|
constructor(expr: any);
|
|
7
|
-
_deriveArray(fn: (arr: any[] |
|
|
12
|
+
_deriveArray(fn: (arr: any[] | AnyTypedArray) => any): any;
|
|
13
|
+
/**
|
|
14
|
+
* Returns true if all items in nested list cells are truthy.
|
|
15
|
+
* @returns ColumnExpression
|
|
16
|
+
* @example
|
|
17
|
+
* >>> const df = $df.data({ a: [[true, true], [true, false]] })
|
|
18
|
+
* >>> df.with_columns($df.col("a").arr.all().alias("all_true"))
|
|
19
|
+
* shape: (2, 2)
|
|
20
|
+
* ┌───────────────┬──────────┐
|
|
21
|
+
* │ a │ all_true │
|
|
22
|
+
* ├───────────────┼──────────┤
|
|
23
|
+
* │ [true, true] │ true │
|
|
24
|
+
* │ [true, false] │ false │
|
|
25
|
+
* └───────────────┴──────────┘
|
|
26
|
+
*/
|
|
8
27
|
all(): any;
|
|
28
|
+
/**
|
|
29
|
+
* Returns true if any item in nested list cells is truthy.
|
|
30
|
+
* @returns ColumnExpression
|
|
31
|
+
* @example
|
|
32
|
+
* >>> const df = $df.data({ a: [[true, false], [false, false]] })
|
|
33
|
+
* >>> df.with_columns($df.col("a").arr.any().alias("any_true"))
|
|
34
|
+
* shape: (2, 2)
|
|
35
|
+
* ┌────────────────┬──────────┐
|
|
36
|
+
* │ a │ any_true │
|
|
37
|
+
* ├────────────────┼──────────┤
|
|
38
|
+
* │ [true, false] │ true │
|
|
39
|
+
* │ [false, false] │ false │
|
|
40
|
+
* └────────────────┴──────────┘
|
|
41
|
+
*/
|
|
9
42
|
any(): any;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if nested lists contain item.
|
|
45
|
+
* @param item The element to search for.
|
|
46
|
+
* @returns ColumnExpression
|
|
47
|
+
* @example
|
|
48
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
49
|
+
* >>> df.with_columns($df.col("a").arr.contains(3).alias("has_three"))
|
|
50
|
+
* shape: (2, 2)
|
|
51
|
+
* ┌───────────┬───────────┐
|
|
52
|
+
* │ a │ has_three │
|
|
53
|
+
* ├───────────┼───────────┤
|
|
54
|
+
* │ [1, 2, 3] │ true │
|
|
55
|
+
* │ [4, 5] │ false │
|
|
56
|
+
* └───────────┴───────────┘
|
|
57
|
+
*/
|
|
10
58
|
contains(item: any): any;
|
|
59
|
+
/**
|
|
60
|
+
* Checks if nested lists contain all elements in items.
|
|
61
|
+
* @param items Array of elements that must all be present.
|
|
62
|
+
* @returns ColumnExpression
|
|
63
|
+
* @example
|
|
64
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [1, 5]] })
|
|
65
|
+
* >>> df.with_columns($df.col("a").arr.contains_all([1, 2]).alias("has_all"))
|
|
66
|
+
* shape: (2, 2)
|
|
67
|
+
* ┌───────────┬─────────┐
|
|
68
|
+
* │ a │ has_all │
|
|
69
|
+
* ├───────────┼─────────┤
|
|
70
|
+
* │ [1, 2, 3] │ true │
|
|
71
|
+
* │ [1, 5] │ false │
|
|
72
|
+
* └───────────┴─────────┘
|
|
73
|
+
*/
|
|
11
74
|
contains_all(items: ArrayLike<any>): any;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if nested lists contain any element in items.
|
|
77
|
+
* @param items Array of elements where at least one must be present.
|
|
78
|
+
* @returns ColumnExpression
|
|
79
|
+
* @example
|
|
80
|
+
* >>> const df = $df.data({ a: [[1, 2], [3, 4]] })
|
|
81
|
+
* >>> df.with_columns($df.col("a").arr.contains_any([2, 3]).alias("has_any"))
|
|
82
|
+
* shape: (2, 2)
|
|
83
|
+
* ┌────────┬─────────┐
|
|
84
|
+
* │ a │ has_any │
|
|
85
|
+
* ├────────┼─────────┤
|
|
86
|
+
* │ [1, 2] │ true │
|
|
87
|
+
* │ [3, 4] │ true │
|
|
88
|
+
* └────────┴─────────┘
|
|
89
|
+
*/
|
|
12
90
|
contains_any(items: ArrayLike<any>): any;
|
|
13
|
-
|
|
14
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Counts occurrence frequency of item inside nested lists.
|
|
93
|
+
* @param item The value to count occurrences of.
|
|
94
|
+
* @param options Statistics and matching options.
|
|
95
|
+
* @returns ColumnExpression
|
|
96
|
+
* @example
|
|
97
|
+
* >>> const df = $df.data({ a: [[1, 2, 2, 3], [4, 5]] })
|
|
98
|
+
* >>> df.with_columns($df.col("a").arr.count_matches(2).alias("twos"))
|
|
99
|
+
* shape: (2, 2)
|
|
100
|
+
* ┌──────────────┬──────┐
|
|
101
|
+
* │ a │ twos │
|
|
102
|
+
* ├──────────────┼──────┤
|
|
103
|
+
* │ [1, 2, 2, 3] │ 2 │
|
|
104
|
+
* │ [4, 5] │ 0 │
|
|
105
|
+
* └──────────────┴──────┘
|
|
106
|
+
*/
|
|
107
|
+
count_matches(item: any, options?: UniqueArrayStatsOptions): any;
|
|
108
|
+
/**
|
|
109
|
+
* Filters elements of list columns matching a boolean sub-expression.
|
|
110
|
+
* @param expr The boolean column expression to filter by.
|
|
111
|
+
* @returns ColumnExpression
|
|
112
|
+
* @example
|
|
113
|
+
* >>> const df = $df.data({ a: [[1, 5, 10], [2, 8]] })
|
|
114
|
+
* >>> df.with_columns($df.col("a").arr.filter($df.element().gt(4)).alias("filtered"))
|
|
115
|
+
* shape: (2, 2)
|
|
116
|
+
* ┌────────────┬──────────┐
|
|
117
|
+
* │ a │ filtered │
|
|
118
|
+
* ├────────────┼──────────┤
|
|
119
|
+
* │ [1, 5, 10] │ [5, 10] │
|
|
120
|
+
* │ [2, 8] │ [8] │
|
|
121
|
+
* └────────────┴──────────┘
|
|
122
|
+
*/
|
|
123
|
+
filter(expr: IExpr): any;
|
|
124
|
+
/**
|
|
125
|
+
* Expands lists into row-wise records.
|
|
126
|
+
* @param options Config options including handling of empty arrays and nulls.
|
|
127
|
+
* @returns ColumnExpression
|
|
128
|
+
* @example
|
|
129
|
+
* >>> const df = $df.data({ a: [[1, 2], [3]] })
|
|
130
|
+
* >>> df.explode($df.col("a").arr.explode())
|
|
131
|
+
* shape: (3, 1)
|
|
132
|
+
* ┌───┐
|
|
133
|
+
* │ a │
|
|
134
|
+
* ├───┤
|
|
135
|
+
* │ 1 │
|
|
136
|
+
* │ 2 │
|
|
137
|
+
* │ 3 │
|
|
138
|
+
* └───┘
|
|
139
|
+
*/
|
|
15
140
|
explode({ empty_as_null, keep_nulls }?: ExplodeOptions): any;
|
|
141
|
+
/**
|
|
142
|
+
* Returns the first element of each list.
|
|
143
|
+
* @param null_on_oob If true, returns null if the list is empty (default: true).
|
|
144
|
+
* @returns ColumnExpression
|
|
145
|
+
* @example
|
|
146
|
+
* >>> const df = $df.data({ a: [[10, 20], [30]] })
|
|
147
|
+
* >>> df.with_columns($df.col("a").arr.first().alias("first_a"))
|
|
148
|
+
* shape: (2, 2)
|
|
149
|
+
* ┌──────────┬─────────┐
|
|
150
|
+
* │ a │ first_a │
|
|
151
|
+
* ├──────────┼─────────┤
|
|
152
|
+
* │ [10, 20] │ 10 │
|
|
153
|
+
* │ [30] │ 30 │
|
|
154
|
+
* └──────────┴─────────┘
|
|
155
|
+
*/
|
|
16
156
|
first(null_on_oob?: boolean): any;
|
|
157
|
+
/**
|
|
158
|
+
* Gathers specific indices from each nested list.
|
|
159
|
+
* @param indices Index or array of indices to extract.
|
|
160
|
+
* @param null_on_oob If true, returns null for indices out of bounds (default: true).
|
|
161
|
+
* @returns ColumnExpression
|
|
162
|
+
* @example
|
|
163
|
+
* >>> const df = $df.data({ a: [[10, 20, 30], [40, 50]] })
|
|
164
|
+
* >>> df.with_columns($df.col("a").arr.gather([0, 2]).alias("g"))
|
|
165
|
+
* shape: (2, 2)
|
|
166
|
+
* ┌──────────────┬──────────┐
|
|
167
|
+
* │ a │ g │
|
|
168
|
+
* ├──────────────┼──────────┤
|
|
169
|
+
* │ [10, 20, 30] │ [10, 30] │
|
|
170
|
+
* │ [40, 50] │ [40, null]│
|
|
171
|
+
* └──────────────┴──────────┘
|
|
172
|
+
*/
|
|
17
173
|
gather(indices: number | ArrayLike<number>, null_on_oob?: boolean): any;
|
|
174
|
+
/**
|
|
175
|
+
* Gather element slices with custom steps.
|
|
176
|
+
* @param options Config options including offset, limit, and step size.
|
|
177
|
+
* @returns ColumnExpression
|
|
178
|
+
* @example
|
|
179
|
+
* >>> const df = $df.data({ a: [[1, 2, 3, 4], [5, 6, 7]] })
|
|
180
|
+
* >>> df.with_columns($df.col("a").arr.gather_every({ step: 2 }).alias("ge"))
|
|
181
|
+
* shape: (2, 2)
|
|
182
|
+
* ┌──────────────┬────────┐
|
|
183
|
+
* │ a │ ge │
|
|
184
|
+
* ├──────────────┼────────┤
|
|
185
|
+
* │ [1, 2, 3, 4] │ [1, 3] │
|
|
186
|
+
* │ [5, 6, 7] │ [5, 7] │
|
|
187
|
+
* └──────────────┴────────┘
|
|
188
|
+
*/
|
|
18
189
|
gather_every(options?: StepSliceArrayOptions): any;
|
|
190
|
+
/**
|
|
191
|
+
* Extracts a single list element by its index position.
|
|
192
|
+
* @param index The 0-based or negative index position to extract.
|
|
193
|
+
* @param null_on_oob If true, returns null if index is out of bounds (default: true).
|
|
194
|
+
* @returns ColumnExpression
|
|
195
|
+
* @example
|
|
196
|
+
* >>> const df = $df.data({ a: [[10, 20], [30]] })
|
|
197
|
+
* >>> df.with_columns($df.col("a").arr.get(1).alias("second"))
|
|
198
|
+
* shape: (2, 2)
|
|
199
|
+
* ┌──────────┬────────┐
|
|
200
|
+
* │ a │ second │
|
|
201
|
+
* ├──────────┼────────┤
|
|
202
|
+
* │ [10, 20] │ 20 │
|
|
203
|
+
* │ [30] │ null │
|
|
204
|
+
* └──────────┴────────┘
|
|
205
|
+
*/
|
|
19
206
|
get(index: number, null_on_oob?: boolean): any;
|
|
207
|
+
/**
|
|
208
|
+
* Joins elements of list columns into a single string column.
|
|
209
|
+
* @param separator The character sequence separating list elements.
|
|
210
|
+
* @param options String conversion options.
|
|
211
|
+
* @returns ColumnExpression
|
|
212
|
+
* @example
|
|
213
|
+
* >>> const df = $df.data({ a: [["a", "b"], ["c"]] })
|
|
214
|
+
* >>> df.with_columns($df.col("a").arr.join("-").alias("joined"))
|
|
215
|
+
* shape: (2, 2)
|
|
216
|
+
* ┌──────────┬────────┐
|
|
217
|
+
* │ a │ joined │
|
|
218
|
+
* ├──────────┼────────┤
|
|
219
|
+
* │ ["a","b"]│ "a-b" │
|
|
220
|
+
* │ ["c"] │ "c" │
|
|
221
|
+
* └──────────┴────────┘
|
|
222
|
+
*/
|
|
20
223
|
join(separator?: string, options?: JoinArrayOptions): any;
|
|
224
|
+
/**
|
|
225
|
+
* Returns the last element of each list.
|
|
226
|
+
* @param null_on_oob If true, returns null if the list is empty (default: true).
|
|
227
|
+
* @returns ColumnExpression
|
|
228
|
+
* @example
|
|
229
|
+
* >>> const df = $df.data({ a: [[10, 20], [30]] })
|
|
230
|
+
* >>> df.with_columns($df.col("a").arr.last().alias("last_a"))
|
|
231
|
+
* shape: (2, 2)
|
|
232
|
+
* ┌──────────┬────────┐
|
|
233
|
+
* │ a │ last_a │
|
|
234
|
+
* ├──────────┼────────┤
|
|
235
|
+
* │ [10, 20] │ 20 │
|
|
236
|
+
* │ [30] │ 30 │
|
|
237
|
+
* └──────────┴────────┐
|
|
238
|
+
*/
|
|
21
239
|
last(null_on_oob?: boolean): any;
|
|
240
|
+
/**
|
|
241
|
+
* Returns the length of each list inside the column cell.
|
|
242
|
+
*/
|
|
22
243
|
len(): any;
|
|
244
|
+
/**
|
|
245
|
+
* Returns the length of each list inside the column cell.
|
|
246
|
+
* @returns ColumnExpression
|
|
247
|
+
* @example
|
|
248
|
+
* >>> const df = $df.data({ a: [[10, 20], [30, 40, 50]] })
|
|
249
|
+
* >>> df.with_columns($df.col("a").arr.lengths().alias("len_a"))
|
|
250
|
+
* shape: (2, 2)
|
|
251
|
+
* ┌──────────────┬───────┐
|
|
252
|
+
* │ a │ len_a │
|
|
253
|
+
* ├──────────────┼───────┤
|
|
254
|
+
* │ [10, 20] │ 2 │
|
|
255
|
+
* │ [30, 40, 50] │ 3 │
|
|
256
|
+
* └──────────────┴───────┘
|
|
257
|
+
*/
|
|
23
258
|
lengths(): any;
|
|
259
|
+
/**
|
|
260
|
+
* Returns the maximum value of elements inside each list.
|
|
261
|
+
* @returns ColumnExpression
|
|
262
|
+
* @example
|
|
263
|
+
* >>> const df = $df.data({ a: [[1, 5, 2], [10, 4]] })
|
|
264
|
+
* >>> df.with_columns($df.col("a").arr.max().alias("max_a"))
|
|
265
|
+
* shape: (2, 2)
|
|
266
|
+
* ┌───────────┬───────┐
|
|
267
|
+
* │ a │ max_a │
|
|
268
|
+
* ├───────────┼───────┤
|
|
269
|
+
* │ [1, 5, 2] │ 5 │
|
|
270
|
+
* │ [10, 4] │ 10 │
|
|
271
|
+
* └───────────┴───────┘
|
|
272
|
+
*/
|
|
24
273
|
max(): any;
|
|
274
|
+
/**
|
|
275
|
+
* Returns the index of maximum value.
|
|
276
|
+
* @returns ColumnExpression
|
|
277
|
+
* @example
|
|
278
|
+
* >>> const df = $df.data({ a: [[1, 5, 2], [10, 4]] })
|
|
279
|
+
* >>> df.with_columns($df.col("a").arr.max_index().alias("max_idx"))
|
|
280
|
+
* shape: (2, 2)
|
|
281
|
+
* ┌───────────┬─────────┐
|
|
282
|
+
* │ a │ max_idx │
|
|
283
|
+
* ├───────────┼─────────┤
|
|
284
|
+
* │ [1, 5, 2] │ 1 │
|
|
285
|
+
* │ [10, 4] │ 0 │
|
|
286
|
+
* └───────────┴─────────┘
|
|
287
|
+
*/
|
|
288
|
+
max_index(): any;
|
|
289
|
+
/**
|
|
290
|
+
* Returns average of elements inside each list.
|
|
291
|
+
* @returns ColumnExpression
|
|
292
|
+
* @example
|
|
293
|
+
* >>> const df = $df.data({ a: [[1, 5, 9], [10, 40]] })
|
|
294
|
+
* >>> df.with_columns($df.col("a").arr.mean().alias("mean_a"))
|
|
295
|
+
* shape: (2, 2)
|
|
296
|
+
* ┌───────────┬────────┐
|
|
297
|
+
* │ a │ mean_a │
|
|
298
|
+
* ├───────────┼────────┤
|
|
299
|
+
* │ [1, 5, 9] │ 5 │
|
|
300
|
+
* │ [10, 40] │ 25 │
|
|
301
|
+
* └───────────┴────────┘
|
|
302
|
+
*/
|
|
25
303
|
mean(): any;
|
|
304
|
+
/**
|
|
305
|
+
* Returns statistical median inside each list.
|
|
306
|
+
* @returns ColumnExpression
|
|
307
|
+
* @example
|
|
308
|
+
* >>> const df = $df.data({ a: [[1, 3, 5, 7], [10, 20, 30]] })
|
|
309
|
+
* >>> df.with_columns($df.col("a").arr.median().alias("med"))
|
|
310
|
+
* shape: (2, 2)
|
|
311
|
+
* ┌────────────────┬──────┐
|
|
312
|
+
* │ a │ med │
|
|
313
|
+
* ├────────────────┼──────┤
|
|
314
|
+
* │ [1, 3, 5, 7] │ 4 │
|
|
315
|
+
* │ [10, 20, 30] │ 20 │
|
|
316
|
+
* └────────────────┴──────┘
|
|
317
|
+
*/
|
|
26
318
|
median(): any;
|
|
319
|
+
/**
|
|
320
|
+
* Returns minimum of elements inside each list.
|
|
321
|
+
* @returns ColumnExpression
|
|
322
|
+
* @example
|
|
323
|
+
* >>> const df = $df.data({ a: [[1, 5, 2], [10, 4]] })
|
|
324
|
+
* >>> df.with_columns($df.col("a").arr.min().alias("min_a"))
|
|
325
|
+
* shape: (2, 2)
|
|
326
|
+
* ┌───────────┬───────┐
|
|
327
|
+
* │ a │ min_a │
|
|
328
|
+
* ├───────────┼───────┤
|
|
329
|
+
* │ [1, 5, 2] │ 1 │
|
|
330
|
+
* │ [10, 4] │ 4 │
|
|
331
|
+
* └───────────┴───────┘
|
|
332
|
+
*/
|
|
27
333
|
min(): any;
|
|
334
|
+
/**
|
|
335
|
+
* Returns the index of minimum value.
|
|
336
|
+
* @returns ColumnExpression
|
|
337
|
+
* @example
|
|
338
|
+
* >>> const df = $df.data({ a: [[5, 1, 2], [10, 4]] })
|
|
339
|
+
* >>> df.with_columns($df.col("a").arr.min_index().alias("min_idx"))
|
|
340
|
+
* shape: (2, 2)
|
|
341
|
+
* ┌───────────┬─────────┐
|
|
342
|
+
* │ a │ min_idx │
|
|
343
|
+
* ├───────────┼─────────┤
|
|
344
|
+
* │ [5, 1, 2] │ 1 │
|
|
345
|
+
* │ [10, 4] │ 1 │
|
|
346
|
+
* └───────────┴─────────┘
|
|
347
|
+
*/
|
|
348
|
+
min_index(): any;
|
|
349
|
+
/**
|
|
350
|
+
* Returns the mode value inside each list.
|
|
351
|
+
* @returns ColumnExpression
|
|
352
|
+
* @example
|
|
353
|
+
* >>> const df = $df.data({ a: [[1, 2, 2, 3], [5, 5, 6]] })
|
|
354
|
+
* >>> df.with_columns($df.col("a").arr.mode().alias("mode_a"))
|
|
355
|
+
* shape: (2, 2)
|
|
356
|
+
* ┌──────────────┬────────┐
|
|
357
|
+
* │ a │ mode_a │
|
|
358
|
+
* ├──────────────┼────────┤
|
|
359
|
+
* │ [1, 2, 2, 3] │ 2 │
|
|
360
|
+
* │ [5, 5, 6] │ 5 │
|
|
361
|
+
* └──────────────┴────────┘
|
|
362
|
+
*/
|
|
28
363
|
mode(): any;
|
|
364
|
+
/**
|
|
365
|
+
* Returns the unique count of elements inside each list.
|
|
366
|
+
* @param options Formatting/statistics parameters.
|
|
367
|
+
* @returns ColumnExpression
|
|
368
|
+
* @example
|
|
369
|
+
* >>> const df = $df.data({ a: [[1, 2, 2, 3], [4, 5]] })
|
|
370
|
+
* >>> df.with_columns($df.col("a").arr.n_unique().alias("unique_len"))
|
|
371
|
+
* shape: (2, 2)
|
|
372
|
+
* ┌──────────────┬────────────┐
|
|
373
|
+
* │ a │ unique_len │
|
|
374
|
+
* ├──────────────┼────────────┤
|
|
375
|
+
* │ [1, 2, 2, 3] │ 3 │
|
|
376
|
+
* │ [4, 5] │ 2 │
|
|
377
|
+
* └──────────────┴────────────┘
|
|
378
|
+
*/
|
|
29
379
|
n_unique(options?: UniqueArrayStatsOptions): any;
|
|
380
|
+
/**
|
|
381
|
+
* Reverses elements of list columns.
|
|
382
|
+
* @returns ColumnExpression
|
|
383
|
+
* @example
|
|
384
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
385
|
+
* >>> df.with_columns($df.col("a").arr.reverse().alias("reversed"))
|
|
386
|
+
* shape: (2, 2)
|
|
387
|
+
* ┌───────────┬───────────┐
|
|
388
|
+
* │ a │ reversed │
|
|
389
|
+
* ├───────────┼───────────┤
|
|
390
|
+
* │ [1, 2, 3] │ [3, 2, 1] │
|
|
391
|
+
* │ [4, 5] │ [5, 4] │
|
|
392
|
+
* └───────────┴───────────┘
|
|
393
|
+
*/
|
|
30
394
|
reverse(): any;
|
|
31
|
-
|
|
395
|
+
/**
|
|
396
|
+
* Shifts elements of list columns by N offsets.
|
|
397
|
+
* @param n Positive or negative offsets shift amount (default: 1).
|
|
398
|
+
* @returns ColumnExpression
|
|
399
|
+
* @example
|
|
400
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
401
|
+
* >>> df.with_columns($df.col("a").arr.shift(1).alias("shifted"))
|
|
402
|
+
* shape: (2, 2)
|
|
403
|
+
* ┌───────────┬──────────────────┐
|
|
404
|
+
* │ a │ shifted │
|
|
405
|
+
* ├───────────┼──────────────────┤
|
|
406
|
+
* │ [1, 2, 3] │ [null, 1, 2] │
|
|
407
|
+
* │ [4, 5] │ [null, 4] │
|
|
408
|
+
* └───────────┴──────────────────┘
|
|
409
|
+
*/
|
|
410
|
+
shift(n?: number): any;
|
|
411
|
+
/**
|
|
412
|
+
* Slices nested list arrays.
|
|
413
|
+
* @param start The slice starting index.
|
|
414
|
+
* @param end The slice ending index.
|
|
415
|
+
* @returns ColumnExpression
|
|
416
|
+
* @example
|
|
417
|
+
* >>> const df = $df.data({ a: [[1, 2, 3, 4], [5, 6]] })
|
|
418
|
+
* >>> df.with_columns($df.col("a").arr.slice(1, 3).alias("sliced"))
|
|
419
|
+
* shape: (2, 2)
|
|
420
|
+
* ┌──────────────┬────────┐
|
|
421
|
+
* │ a │ sliced │
|
|
422
|
+
* ├──────────────┼────────┤
|
|
423
|
+
* │ [1, 2, 3, 4] │ [2, 3] │
|
|
424
|
+
* │ [5, 6] │ [6] │
|
|
425
|
+
* └──────────────┴────────┘
|
|
426
|
+
*/
|
|
427
|
+
slice(start?: number, end?: number): any;
|
|
428
|
+
/**
|
|
429
|
+
* Splices elements in list cells.
|
|
430
|
+
* @param start The index where array modifications begin.
|
|
431
|
+
* @param deleteCount The number of elements to remove.
|
|
432
|
+
* @param items The elements to insert.
|
|
433
|
+
* @returns ColumnExpression
|
|
434
|
+
* @example
|
|
435
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
436
|
+
* >>> df.with_columns($df.col("a").arr.splice(1, 1, 10, 20).alias("spliced"))
|
|
437
|
+
* shape: (2, 2)
|
|
438
|
+
* ┌───────────┬─────────────────┐
|
|
439
|
+
* │ a │ spliced │
|
|
440
|
+
* ├───────────┼─────────────────┤
|
|
441
|
+
* │ [1, 2, 3] │ [1, 10, 20, 3] │
|
|
442
|
+
* │ [4, 5] │ [4, 10, 20] │
|
|
443
|
+
* └───────────┴─────────────────┘
|
|
444
|
+
*/
|
|
445
|
+
splice(start: number, deleteCount?: number, ...items: any[]): any;
|
|
446
|
+
/**
|
|
447
|
+
* Sorts elements inside each list.
|
|
448
|
+
* @param options Sort customization parameters (e.g. descending flag).
|
|
449
|
+
* @returns ColumnExpression
|
|
450
|
+
* @example
|
|
451
|
+
* >>> const df = $df.data({ a: [[3, 1, 2], [5, 4]] })
|
|
452
|
+
* >>> df.with_columns($df.col("a").arr.sort().alias("sorted"))
|
|
453
|
+
* shape: (2, 2)
|
|
454
|
+
* ┌───────────┬───────────┐
|
|
455
|
+
* │ a │ sorted │
|
|
456
|
+
* ├───────────┼───────────┤
|
|
457
|
+
* │ [3, 1, 2] │ [1, 2, 3] │
|
|
458
|
+
* │ [5, 4] │ [4, 5] │
|
|
459
|
+
* └───────────┴───────────┘
|
|
460
|
+
*/
|
|
32
461
|
sort(options?: SortArrayOptions): any;
|
|
462
|
+
/**
|
|
463
|
+
* Returns sample standard deviation of elements inside each list.
|
|
464
|
+
* @returns ColumnExpression
|
|
465
|
+
* @example
|
|
466
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [10, 20]] })
|
|
467
|
+
* >>> df.with_columns($df.col("a").arr.std().alias("std_dev"))
|
|
468
|
+
* shape: (2, 2)
|
|
469
|
+
* ┌───────────┬─────────┐
|
|
470
|
+
* │ a │ std_dev │
|
|
471
|
+
* ├───────────┼─────────┤
|
|
472
|
+
* │ [1, 2, 3] │ 1 │
|
|
473
|
+
* │ [10, 20] │ 7.071 │
|
|
474
|
+
* └───────────┴─────────┘
|
|
475
|
+
*/
|
|
476
|
+
std(): any;
|
|
477
|
+
/**
|
|
478
|
+
* Returns sum of elements inside each list.
|
|
479
|
+
* @returns ColumnExpression
|
|
480
|
+
* @example
|
|
481
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [10, 20]] })
|
|
482
|
+
* >>> df.with_columns($df.col("a").arr.sum().alias("sum_a"))
|
|
483
|
+
* shape: (2, 2)
|
|
484
|
+
* ┌───────────┬───────┐
|
|
485
|
+
* │ a │ sum_a │
|
|
486
|
+
* ├───────────┼───────┤
|
|
487
|
+
* │ [1, 2, 3] │ 6 │
|
|
488
|
+
* │ [10, 20] │ 30 │
|
|
489
|
+
* └───────────┴───────┘
|
|
490
|
+
*/
|
|
33
491
|
sum(): any;
|
|
492
|
+
/**
|
|
493
|
+
* Converts list column elements to struct columns.
|
|
494
|
+
* @param options Config flags including custom field names or upper bound size.
|
|
495
|
+
* @returns ColumnExpression
|
|
496
|
+
* @example
|
|
497
|
+
* >>> const df = $df.data({ a: [[1, 2], [3, 4]] })
|
|
498
|
+
* >>> df.with_columns($df.col("a").arr.to_struct({ fields: ["x", "y"] }).alias("struct_a"))
|
|
499
|
+
* shape: (2, 2)
|
|
500
|
+
* ┌────────┬────────────────┐
|
|
501
|
+
* │ a │ struct_a │
|
|
502
|
+
* ├────────┼────────────────┤
|
|
503
|
+
* │ [1, 2] │ { x: 1, y: 2 } │
|
|
504
|
+
* │ [3, 4] │ { x: 3, y: 4 } │
|
|
505
|
+
* └────────┴────────────────┘
|
|
506
|
+
*/
|
|
507
|
+
to_struct({ upper_bound, fields }?: ToStructOptions): any;
|
|
508
|
+
/**
|
|
509
|
+
* Fills each list with unique elements only.
|
|
510
|
+
* @param options Custom uniqueness matching configuration.
|
|
511
|
+
* @returns ColumnExpression
|
|
512
|
+
* @example
|
|
513
|
+
* >>> const df = $df.data({ a: [[1, 2, 2, 3], [4, 4, 5]] })
|
|
514
|
+
* >>> df.with_columns($df.col("a").arr.unique().alias("unique_a"))
|
|
515
|
+
* shape: (2, 2)
|
|
516
|
+
* ┌──────────────┬───────────┐
|
|
517
|
+
* │ a │ unique_a │
|
|
518
|
+
* ├──────────────┼───────────┤
|
|
519
|
+
* │ [1, 2, 2, 3] │ [1, 2, 3] │
|
|
520
|
+
* │ [4, 4, 5] │ [4, 5] │
|
|
521
|
+
* └──────────────┴───────────┘
|
|
522
|
+
*/
|
|
34
523
|
unique(options?: UniqueArrayStatsOptions): any;
|
|
524
|
+
/**
|
|
525
|
+
* Returns sample variance of elements inside each list.
|
|
526
|
+
* @returns ColumnExpression
|
|
527
|
+
* @example
|
|
528
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [10, 20]] })
|
|
529
|
+
* >>> df.with_columns($df.col("a").arr.variance().alias("var_a"))
|
|
530
|
+
* shape: (2, 2)
|
|
531
|
+
* ┌───────────┬───────┐
|
|
532
|
+
* │ a │ var_a │
|
|
533
|
+
* ├───────────┼───────┤
|
|
534
|
+
* │ [1, 2, 3] │ 1 │
|
|
535
|
+
* │ [10, 20] │ 50 │
|
|
536
|
+
* └───────────┴───────┘
|
|
537
|
+
*/
|
|
538
|
+
variance(): any;
|
|
539
|
+
/**
|
|
540
|
+
* Evaluates subExpr element-wise across array lists.
|
|
541
|
+
* @param expr The sub-expression to evaluate inside each nested list.
|
|
542
|
+
* @returns ColumnExpression
|
|
543
|
+
* @example
|
|
544
|
+
* >>> const df = $df.data({ a: [[1, 2], [3, 4]] })
|
|
545
|
+
* >>> df.with_columns($df.col("a").arr.eval($df.element().mul(10)).alias("multiplied"))
|
|
546
|
+
* shape: (2, 2)
|
|
547
|
+
* ┌────────┬────────────┐
|
|
548
|
+
* │ a │ multiplied │
|
|
549
|
+
* ├────────┼────────────┤
|
|
550
|
+
* │ [1, 2] │ [10, 20] │
|
|
551
|
+
* │ [3, 4] │ [30, 40] │
|
|
552
|
+
* └────────┴────────────┘
|
|
553
|
+
*/
|
|
35
554
|
eval(expr: IExpr): any;
|
|
36
555
|
}
|
|
37
556
|
export declare class ArrayExpr extends ExprBase {
|
|
557
|
+
/**
|
|
558
|
+
* Array namespace accessor for list-based column operations.
|
|
559
|
+
* @namespace $df.col
|
|
560
|
+
* @category ColumnExpression
|
|
561
|
+
* @syntax $df.col(<column_name>).arr
|
|
562
|
+
* @returns ArrayExprNamespace
|
|
563
|
+
* @example
|
|
564
|
+
* >>> df.select($df.col("a").arr.len())
|
|
565
|
+
*/
|
|
38
566
|
get arr(): ArrayExprNamespace;
|
|
39
567
|
}
|