df-script 1.8.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 +153 -203
- package/dist/api.d.ts +41 -36
- package/dist/columnExpressions/ColumnExpr.d.ts +5 -8
- package/dist/columnExpressions/ExprBase.d.ts +7 -0
- package/dist/columnExpressions/constants.d.ts +1 -0
- 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 +31 -32
- package/dist/columnExpressions/index.d.ts +4 -7
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +672 -141
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +701 -327
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +543 -231
- 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 +1299 -396
- package/dist/columnExpressions/mixins/StructExpr.d.ts +72 -30
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +518 -212
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +270 -102
- package/dist/columnExpressions/typeInference.d.ts +13 -0
- package/dist/columnExpressions/types.d.ts +6 -1
- package/dist/columnExpressions/utils.d.ts +16 -0
- package/dist/constants.d.ts +38 -0
- package/dist/dataframe/dataframe.d.ts +755 -608
- 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 +148 -7
- package/dist/utils/array.d.ts +54 -18
- package/dist/utils/binary.d.ts +6 -2
- 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 +56 -2
- package/dist/utils/number.d.ts +5 -2
- package/dist/utils/object.d.ts +7 -12
- package/dist/utils/string.d.ts +83 -2
- package/dist/utils/table.d.ts +76 -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
|
@@ -7,17 +7,26 @@ import { ExprBase } from "../ExprBase";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class WindowExpr extends ExprBase {
|
|
9
9
|
_partitionBy: (string | IExpr)[] | null;
|
|
10
|
-
_window(evaluateWindow: (this: IExpr, groupPreValues: any[], partitionIndices: number[], currentIndex: number) => any): this;
|
|
11
|
-
_rolling(windowSize: number, aggFn: (vals: any[]) => any): this;
|
|
12
10
|
_cum(reverse: boolean, initialVal: any, stepFn: (acc: any, val: any) => any, postFn?: (acc: any, hasValid: boolean) => any): this;
|
|
13
11
|
get _isWindow(): boolean;
|
|
12
|
+
_rolling(windowSize: number, aggFn: (vals: any[]) => any): this;
|
|
13
|
+
_window(evaluateWindow: (this: IExpr, groupPreValues: any[], partitionIndices: number[], currentIndex: number) => any): this;
|
|
14
14
|
/**
|
|
15
15
|
* Window: Computes cumulative count.
|
|
16
16
|
* @param reverse Flag indicating whether to compute from reverse direction.
|
|
17
17
|
* @returns ColumnExpression
|
|
18
18
|
* @example
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
20
|
+
* >>> df
|
|
21
|
+
* shape: (3, 1)
|
|
22
|
+
* ┌───┐
|
|
23
|
+
* │ a │
|
|
24
|
+
* ├───┤
|
|
25
|
+
* │ 1 │
|
|
26
|
+
* │ 2 │
|
|
27
|
+
* │ 3 │
|
|
28
|
+
* └───┘
|
|
29
|
+
* >>> df.withColumns($df.col("val").cumCount().alias("c_count"))
|
|
21
30
|
* shape: (3, 2)
|
|
22
31
|
* ┌─────┬─────────┐
|
|
23
32
|
* │ val │ c_count │
|
|
@@ -27,66 +36,102 @@ export declare class WindowExpr extends ExprBase {
|
|
|
27
36
|
* │ 30 │ 3 │
|
|
28
37
|
* └─────┴─────────┘
|
|
29
38
|
*/
|
|
30
|
-
|
|
39
|
+
cumCount(reverse?: boolean): this;
|
|
31
40
|
/**
|
|
32
41
|
* Window: Computes cumulative maximum value.
|
|
33
42
|
* @param reverse Flag indicating whether to compute in reverse direction.
|
|
34
43
|
* @returns ColumnExpression
|
|
35
44
|
* @example
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
46
|
+
* >>> df
|
|
47
|
+
* shape: (3, 1)
|
|
48
|
+
* ┌───┐
|
|
49
|
+
* │ a │
|
|
50
|
+
* ├───┤
|
|
51
|
+
* │ 1 │
|
|
52
|
+
* │ 2 │
|
|
53
|
+
* │ 3 │
|
|
54
|
+
* └───┘
|
|
55
|
+
* >>> df.withColumns($df.col("val").cumMax().alias("c_max"))
|
|
38
56
|
* shape: (3, 2)
|
|
39
57
|
* ┌─────┬───────┐
|
|
40
58
|
* │ val │ c_max │
|
|
41
59
|
* ├─────┼───────┤
|
|
42
|
-
* │
|
|
43
|
-
* │
|
|
44
|
-
* │
|
|
60
|
+
* │ 10 │ 10 │
|
|
61
|
+
* │ 20 │ 20 │
|
|
62
|
+
* │ 30 │ 30 │
|
|
45
63
|
* └─────┴───────┘
|
|
46
64
|
*/
|
|
47
|
-
|
|
65
|
+
cumMax(reverse?: boolean): this;
|
|
48
66
|
/**
|
|
49
67
|
* Window: Computes cumulative minimum value.
|
|
50
68
|
* @param reverse Flag indicating whether to compute in reverse direction.
|
|
51
69
|
* @returns ColumnExpression
|
|
52
70
|
* @example
|
|
53
|
-
|
|
54
|
-
|
|
71
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
72
|
+
* >>> df
|
|
73
|
+
* shape: (3, 1)
|
|
74
|
+
* ┌───┐
|
|
75
|
+
* │ a │
|
|
76
|
+
* ├───┤
|
|
77
|
+
* │ 1 │
|
|
78
|
+
* │ 2 │
|
|
79
|
+
* │ 3 │
|
|
80
|
+
* └───┘
|
|
81
|
+
* >>> df.withColumns($df.col("val").cumMin().alias("c_min"))
|
|
55
82
|
* shape: (3, 2)
|
|
56
83
|
* ┌─────┬───────┐
|
|
57
84
|
* │ val │ c_min │
|
|
58
85
|
* ├─────┼───────┤
|
|
59
|
-
* │
|
|
60
|
-
* │
|
|
61
|
-
* │
|
|
86
|
+
* │ 10 │ 10 │
|
|
87
|
+
* │ 20 │ 10 │
|
|
88
|
+
* │ 30 │ 10 │
|
|
62
89
|
* └─────┴───────┘
|
|
63
90
|
*/
|
|
64
|
-
|
|
91
|
+
cumMin(reverse?: boolean): this;
|
|
65
92
|
/**
|
|
66
93
|
* Window: Computes cumulative product of values.
|
|
67
94
|
* @param reverse Flag indicating whether to compute in reverse direction.
|
|
68
95
|
* @returns ColumnExpression
|
|
69
96
|
* @example
|
|
70
|
-
|
|
71
|
-
|
|
97
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
98
|
+
* >>> df
|
|
99
|
+
* shape: (3, 1)
|
|
100
|
+
* ┌───┐
|
|
101
|
+
* │ a │
|
|
102
|
+
* ├───┤
|
|
103
|
+
* │ 1 │
|
|
104
|
+
* │ 2 │
|
|
105
|
+
* │ 3 │
|
|
106
|
+
* └───┘
|
|
107
|
+
* >>> df.withColumns($df.col("a").cumProd().alias("c_prod"))
|
|
72
108
|
* shape: (4, 2)
|
|
73
|
-
*
|
|
74
|
-
* │
|
|
75
|
-
*
|
|
76
|
-
* │ 1
|
|
77
|
-
* │ 2
|
|
78
|
-
* │ 3
|
|
79
|
-
* │ 4
|
|
80
|
-
*
|
|
109
|
+
* ┌───┬────────┐
|
|
110
|
+
* │ a │ c_prod │
|
|
111
|
+
* ├───┼────────┤
|
|
112
|
+
* │ 1 │ 1 │
|
|
113
|
+
* │ 2 │ 2 │
|
|
114
|
+
* │ 3 │ 6 │
|
|
115
|
+
* │ 4 │ 24 │
|
|
116
|
+
* └───┴────────┘
|
|
81
117
|
*/
|
|
82
|
-
|
|
118
|
+
cumProd(reverse?: boolean): this;
|
|
83
119
|
/**
|
|
84
120
|
* Window: Computes cumulative sum of values.
|
|
85
121
|
* @param reverse Flag indicating whether to compute in reverse direction.
|
|
86
122
|
* @returns ColumnExpression
|
|
87
123
|
* @example
|
|
88
|
-
|
|
89
|
-
|
|
124
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
125
|
+
* >>> df
|
|
126
|
+
* shape: (3, 1)
|
|
127
|
+
* ┌───┐
|
|
128
|
+
* │ a │
|
|
129
|
+
* ├───┤
|
|
130
|
+
* │ 1 │
|
|
131
|
+
* │ 2 │
|
|
132
|
+
* │ 3 │
|
|
133
|
+
* └───┘
|
|
134
|
+
* >>> df.withColumns($df.col("val").cumSum().alias("c_sum"))
|
|
90
135
|
* shape: (3, 2)
|
|
91
136
|
* ┌─────┬───────┐
|
|
92
137
|
* │ val │ c_sum │
|
|
@@ -96,31 +141,48 @@ export declare class WindowExpr extends ExprBase {
|
|
|
96
141
|
* │ 30 │ 60 │
|
|
97
142
|
* └─────┴───────┘
|
|
98
143
|
*/
|
|
99
|
-
|
|
144
|
+
cumSum(reverse?: boolean): this;
|
|
100
145
|
/**
|
|
101
146
|
* Window: Computes dense rank (ranks without gaps) within group partition.
|
|
102
147
|
* @returns ColumnExpression
|
|
103
148
|
* @example
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
149
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
150
|
+
* >>> df
|
|
151
|
+
* shape: (3, 1)
|
|
152
|
+
* ┌───┐
|
|
153
|
+
* │ a │
|
|
154
|
+
* ├───┤
|
|
155
|
+
* │ 1 │
|
|
156
|
+
* │ 2 │
|
|
157
|
+
* │ 3 │
|
|
158
|
+
* └───┘
|
|
159
|
+
* >>> df.withColumns($df.col("score").denseRank().alias("dr"))
|
|
160
|
+
* shape: (2, 2)
|
|
107
161
|
* ┌───────┬────┐
|
|
108
162
|
* │ score │ dr │
|
|
109
163
|
* ├───────┼────┤
|
|
110
|
-
* │
|
|
111
|
-
* │
|
|
112
|
-
* │ 90 │ 1 │
|
|
164
|
+
* │ 75 │ 1 │
|
|
165
|
+
* │ 95 │ 2 │
|
|
113
166
|
* └───────┴────┘
|
|
114
167
|
*/
|
|
115
|
-
|
|
168
|
+
denseRank(): this;
|
|
116
169
|
/**
|
|
117
170
|
* Window: Shifts values down by offset, filling missing slots with default value.
|
|
118
171
|
* @param offset Number of rows to shift down (default 1).
|
|
119
172
|
* @param defaultVal Fallback fill value for empty slots (default null).
|
|
120
173
|
* @returns ColumnExpression
|
|
121
174
|
* @example
|
|
122
|
-
|
|
123
|
-
|
|
175
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
176
|
+
* >>> df
|
|
177
|
+
* shape: (3, 1)
|
|
178
|
+
* ┌───┐
|
|
179
|
+
* │ a │
|
|
180
|
+
* ├───┤
|
|
181
|
+
* │ 1 │
|
|
182
|
+
* │ 2 │
|
|
183
|
+
* │ 3 │
|
|
184
|
+
* └───┘
|
|
185
|
+
* >>> df.withColumns($df.col("val").lag(1, 0).alias("prev"))
|
|
124
186
|
* shape: (3, 2)
|
|
125
187
|
* ┌─────┬──────┐
|
|
126
188
|
* │ val │ prev │
|
|
@@ -137,8 +199,17 @@ export declare class WindowExpr extends ExprBase {
|
|
|
137
199
|
* @param defaultVal Fallback fill value for empty slots (default null).
|
|
138
200
|
* @returns ColumnExpression
|
|
139
201
|
* @example
|
|
140
|
-
|
|
141
|
-
|
|
202
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
203
|
+
* >>> df
|
|
204
|
+
* shape: (3, 1)
|
|
205
|
+
* ┌───┐
|
|
206
|
+
* │ a │
|
|
207
|
+
* ├───┤
|
|
208
|
+
* │ 1 │
|
|
209
|
+
* │ 2 │
|
|
210
|
+
* │ 3 │
|
|
211
|
+
* └───┘
|
|
212
|
+
* >>> df.withColumns($df.col("val").lead(1, 0).alias("next"))
|
|
142
213
|
* shape: (3, 2)
|
|
143
214
|
* ┌─────┬──────┐
|
|
144
215
|
* │ val │ next │
|
|
@@ -154,31 +225,48 @@ export declare class WindowExpr extends ExprBase {
|
|
|
154
225
|
* @param columns Column expression or array of columns to partition by.
|
|
155
226
|
* @returns ColumnExpression
|
|
156
227
|
* @example
|
|
157
|
-
|
|
158
|
-
|
|
228
|
+
* >>> const df = $df.data({ group: ["A", "A", "B"], val: [10, 20, 30] })
|
|
229
|
+
* >>> df
|
|
230
|
+
* shape: (3, 2)
|
|
231
|
+
* ┌───────┬─────┐
|
|
232
|
+
* │ group │ val │
|
|
233
|
+
* ├───────┼─────┤
|
|
234
|
+
* │ A │ 10 │
|
|
235
|
+
* │ A │ 20 │
|
|
236
|
+
* │ B │ 30 │
|
|
237
|
+
* └───────┴─────┘
|
|
238
|
+
* >>> df.withColumns($df.col("val").sum().over("group").alias("cat_sum"))
|
|
159
239
|
* shape: (3, 3)
|
|
160
|
-
*
|
|
161
|
-
* │
|
|
162
|
-
*
|
|
163
|
-
* │ A
|
|
164
|
-
* │ A
|
|
165
|
-
* │ B
|
|
166
|
-
*
|
|
240
|
+
* ┌───────┬─────┬─────────┐
|
|
241
|
+
* │ group │ val │ cat_sum │
|
|
242
|
+
* ├───────┼─────┼─────────┤
|
|
243
|
+
* │ A │ 10 │ 30 │
|
|
244
|
+
* │ A │ 20 │ 30 │
|
|
245
|
+
* │ B │ 30 │ 30 │
|
|
246
|
+
* └───────┴─────┴─────────┘
|
|
167
247
|
*/
|
|
168
248
|
over(columns: string | IExpr | (string | IExpr)[]): this;
|
|
169
249
|
/**
|
|
170
250
|
* Window: Computes rank within group partition.
|
|
171
251
|
* @returns ColumnExpression
|
|
172
252
|
* @example
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
253
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
254
|
+
* >>> df
|
|
255
|
+
* shape: (3, 1)
|
|
256
|
+
* ┌───┐
|
|
257
|
+
* │ a │
|
|
258
|
+
* ├───┤
|
|
259
|
+
* │ 1 │
|
|
260
|
+
* │ 2 │
|
|
261
|
+
* │ 3 │
|
|
262
|
+
* └───┘
|
|
263
|
+
* >>> df.withColumns($df.col("score").rank().alias("rank"))
|
|
264
|
+
* shape: (2, 2)
|
|
176
265
|
* ┌───────┬──────┐
|
|
177
266
|
* │ score │ rank │
|
|
178
267
|
* ├───────┼──────┤
|
|
179
|
-
* │
|
|
180
|
-
* │
|
|
181
|
-
* │ 90 │ 2 │
|
|
268
|
+
* │ 75 │ 1 │
|
|
269
|
+
* │ 95 │ 2 │
|
|
182
270
|
* └───────┴──────┘
|
|
183
271
|
*/
|
|
184
272
|
rank(): this;
|
|
@@ -187,26 +275,43 @@ export declare class WindowExpr extends ExprBase {
|
|
|
187
275
|
* @param windowSize Size of rolling window.
|
|
188
276
|
* @returns ColumnExpression
|
|
189
277
|
* @example
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
278
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
279
|
+
* >>> df
|
|
280
|
+
* shape: (3, 1)
|
|
281
|
+
* ┌───┐
|
|
282
|
+
* │ a │
|
|
283
|
+
* ├───┤
|
|
284
|
+
* │ 1 │
|
|
285
|
+
* │ 2 │
|
|
286
|
+
* │ 3 │
|
|
287
|
+
* └───┘
|
|
288
|
+
* >>> df.withColumns($df.col("val").rollingMax(2).alias("r_max"))
|
|
289
|
+
* shape: (3, 2)
|
|
193
290
|
* ┌─────┬───────┐
|
|
194
291
|
* │ val │ r_max │
|
|
195
292
|
* ├─────┼───────┤
|
|
196
|
-
* │
|
|
197
|
-
* │
|
|
198
|
-
* │
|
|
199
|
-
* │ 8 │ 8 │
|
|
293
|
+
* │ 10 │ 10 │
|
|
294
|
+
* │ 20 │ 20 │
|
|
295
|
+
* │ 30 │ 30 │
|
|
200
296
|
* └─────┴───────┘
|
|
201
297
|
*/
|
|
202
|
-
|
|
298
|
+
rollingMax(windowSize: number): this;
|
|
203
299
|
/**
|
|
204
300
|
* Window: Computes rolling window mean average.
|
|
205
301
|
* @param windowSize Size of rolling window.
|
|
206
302
|
* @returns ColumnExpression
|
|
207
303
|
* @example
|
|
208
|
-
|
|
209
|
-
|
|
304
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
305
|
+
* >>> df
|
|
306
|
+
* shape: (3, 1)
|
|
307
|
+
* ┌───┐
|
|
308
|
+
* │ a │
|
|
309
|
+
* ├───┤
|
|
310
|
+
* │ 1 │
|
|
311
|
+
* │ 2 │
|
|
312
|
+
* │ 3 │
|
|
313
|
+
* └───┘
|
|
314
|
+
* >>> df.withColumns($df.col("val").rollingMean(2).alias("r_mean"))
|
|
210
315
|
* shape: (3, 2)
|
|
211
316
|
* ┌─────┬────────┐
|
|
212
317
|
* │ val │ r_mean │
|
|
@@ -216,49 +321,76 @@ export declare class WindowExpr extends ExprBase {
|
|
|
216
321
|
* │ 30 │ 25 │
|
|
217
322
|
* └─────┴────────┘
|
|
218
323
|
*/
|
|
219
|
-
|
|
324
|
+
rollingMean(windowSize: number): this;
|
|
220
325
|
/**
|
|
221
326
|
* Window: Computes rolling window median value.
|
|
222
327
|
* @param windowSize Size of rolling window.
|
|
223
328
|
* @returns ColumnExpression
|
|
224
329
|
* @example
|
|
225
|
-
|
|
226
|
-
|
|
330
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
331
|
+
* >>> df
|
|
332
|
+
* shape: (3, 1)
|
|
333
|
+
* ┌───┐
|
|
334
|
+
* │ a │
|
|
335
|
+
* ├───┤
|
|
336
|
+
* │ 1 │
|
|
337
|
+
* │ 2 │
|
|
338
|
+
* │ 3 │
|
|
339
|
+
* └───┘
|
|
340
|
+
* >>> df.withColumns($df.col("val").rollingMedian(2).alias("r_med"))
|
|
227
341
|
* shape: (3, 2)
|
|
228
342
|
* ┌─────┬───────┐
|
|
229
343
|
* │ val │ r_med │
|
|
230
344
|
* ├─────┼───────┤
|
|
231
345
|
* │ 10 │ 10 │
|
|
232
|
-
* │
|
|
233
|
-
* │
|
|
346
|
+
* │ 20 │ 15 │
|
|
347
|
+
* │ 30 │ 25 │
|
|
234
348
|
* └─────┴───────┘
|
|
235
349
|
*/
|
|
236
|
-
|
|
350
|
+
rollingMedian(windowSize: number): this;
|
|
237
351
|
/**
|
|
238
352
|
* Window: Computes rolling window minimum value.
|
|
239
353
|
* @param windowSize Size of rolling window.
|
|
240
354
|
* @returns ColumnExpression
|
|
241
355
|
* @example
|
|
242
|
-
|
|
243
|
-
|
|
356
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
357
|
+
* >>> df
|
|
358
|
+
* shape: (3, 1)
|
|
359
|
+
* ┌───┐
|
|
360
|
+
* │ a │
|
|
361
|
+
* ├───┤
|
|
362
|
+
* │ 1 │
|
|
363
|
+
* │ 2 │
|
|
364
|
+
* │ 3 │
|
|
365
|
+
* └───┘
|
|
366
|
+
* >>> df.withColumns($df.col("val").rollingMin(2).alias("r_min"))
|
|
244
367
|
* shape: (3, 2)
|
|
245
368
|
* ┌─────┬───────┐
|
|
246
369
|
* │ val │ r_min │
|
|
247
370
|
* ├─────┼───────┤
|
|
248
371
|
* │ 10 │ 10 │
|
|
249
|
-
* │
|
|
250
|
-
* │
|
|
372
|
+
* │ 20 │ 10 │
|
|
373
|
+
* │ 30 │ 20 │
|
|
251
374
|
* └─────┴───────┘
|
|
252
375
|
*/
|
|
253
|
-
|
|
376
|
+
rollingMin(windowSize: number): this;
|
|
254
377
|
/**
|
|
255
378
|
* Window: Computes rolling window quantile value.
|
|
256
379
|
* @param quantile Quantile boundary between 0.0 and 1.0.
|
|
257
380
|
* @param windowSize Size of rolling window.
|
|
258
381
|
* @returns ColumnExpression
|
|
259
382
|
* @example
|
|
260
|
-
|
|
261
|
-
|
|
383
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
384
|
+
* >>> df
|
|
385
|
+
* shape: (3, 1)
|
|
386
|
+
* ┌───┐
|
|
387
|
+
* │ a │
|
|
388
|
+
* ├───┤
|
|
389
|
+
* │ 1 │
|
|
390
|
+
* │ 2 │
|
|
391
|
+
* │ 3 │
|
|
392
|
+
* └───┘
|
|
393
|
+
* >>> df.withColumns($df.col("val").rollingQuantile(0.5, 2).alias("r_quant"))
|
|
262
394
|
* shape: (3, 2)
|
|
263
395
|
* ┌─────┬─────────┐
|
|
264
396
|
* │ val │ r_quant │
|
|
@@ -268,31 +400,49 @@ export declare class WindowExpr extends ExprBase {
|
|
|
268
400
|
* │ 30 │ 25 │
|
|
269
401
|
* └─────┴─────────┘
|
|
270
402
|
*/
|
|
271
|
-
|
|
403
|
+
rollingQuantile(quantile: number, windowSize: number): this;
|
|
272
404
|
/**
|
|
273
405
|
* Window: Computes rolling window rank.
|
|
274
406
|
* @param windowSize Size of rolling window.
|
|
275
407
|
* @returns ColumnExpression
|
|
276
408
|
* @example
|
|
277
|
-
|
|
278
|
-
|
|
409
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
410
|
+
* >>> df
|
|
411
|
+
* shape: (3, 1)
|
|
412
|
+
* ┌───┐
|
|
413
|
+
* │ a │
|
|
414
|
+
* ├───┤
|
|
415
|
+
* │ 1 │
|
|
416
|
+
* │ 2 │
|
|
417
|
+
* │ 3 │
|
|
418
|
+
* └───┘
|
|
419
|
+
* >>> df.withColumns($df.col("val").rollingRank(2).alias("r_rank"))
|
|
279
420
|
* shape: (3, 2)
|
|
280
421
|
* ┌─────┬────────┐
|
|
281
422
|
* │ val │ r_rank │
|
|
282
423
|
* ├─────┼────────┤
|
|
283
424
|
* │ 10 │ 1 │
|
|
284
425
|
* │ 20 │ 2 │
|
|
285
|
-
* │
|
|
426
|
+
* │ 30 │ 2 │
|
|
286
427
|
* └─────┴────────┘
|
|
287
428
|
*/
|
|
288
|
-
|
|
429
|
+
rollingRank(windowSize: number): this;
|
|
289
430
|
/**
|
|
290
431
|
* Window: Computes rolling window standard deviation.
|
|
291
432
|
* @param windowSize Size of rolling window.
|
|
292
433
|
* @returns ColumnExpression
|
|
293
434
|
* @example
|
|
294
|
-
|
|
295
|
-
|
|
435
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
436
|
+
* >>> df
|
|
437
|
+
* shape: (3, 1)
|
|
438
|
+
* ┌───┐
|
|
439
|
+
* │ a │
|
|
440
|
+
* ├───┤
|
|
441
|
+
* │ 1 │
|
|
442
|
+
* │ 2 │
|
|
443
|
+
* │ 3 │
|
|
444
|
+
* └───┘
|
|
445
|
+
* >>> df.withColumns($df.col("val").rollingStd(2).alias("r_std"))
|
|
296
446
|
* shape: (3, 2)
|
|
297
447
|
* ┌─────┬────────┐
|
|
298
448
|
* │ val │ r_std │
|
|
@@ -302,14 +452,23 @@ export declare class WindowExpr extends ExprBase {
|
|
|
302
452
|
* │ 30 │ 7.071 │
|
|
303
453
|
* └─────┴────────┘
|
|
304
454
|
*/
|
|
305
|
-
|
|
455
|
+
rollingStd(windowSize: number): this;
|
|
306
456
|
/**
|
|
307
457
|
* Window: Computes rolling window sum.
|
|
308
458
|
* @param windowSize Size of rolling window.
|
|
309
459
|
* @returns ColumnExpression
|
|
310
460
|
* @example
|
|
311
|
-
|
|
312
|
-
|
|
461
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
462
|
+
* >>> df
|
|
463
|
+
* shape: (3, 1)
|
|
464
|
+
* ┌───┐
|
|
465
|
+
* │ a │
|
|
466
|
+
* ├───┤
|
|
467
|
+
* │ 1 │
|
|
468
|
+
* │ 2 │
|
|
469
|
+
* │ 3 │
|
|
470
|
+
* └───┘
|
|
471
|
+
* >>> df.withColumns($df.col("val").rollingSum(2).alias("r_sum"))
|
|
313
472
|
* shape: (3, 2)
|
|
314
473
|
* ┌─────┬───────┐
|
|
315
474
|
* │ val │ r_sum │
|
|
@@ -319,21 +478,30 @@ export declare class WindowExpr extends ExprBase {
|
|
|
319
478
|
* │ 30 │ 50 │
|
|
320
479
|
* └─────┴───────┘
|
|
321
480
|
*/
|
|
322
|
-
|
|
481
|
+
rollingSum(windowSize: number): this;
|
|
323
482
|
/**
|
|
324
483
|
* Window: Computes 1-indexed row number count within group partitions.
|
|
325
484
|
* @returns ColumnExpression
|
|
326
485
|
* @example
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
486
|
+
* >>> const df = $df.data({ group: ["A", "A", "B"], val: [10, 20, 30] })
|
|
487
|
+
* >>> df
|
|
488
|
+
* shape: (3, 2)
|
|
489
|
+
* ┌───────┬─────┐
|
|
490
|
+
* │ group │ val │
|
|
491
|
+
* ├───────┼─────┤
|
|
492
|
+
* │ A │ 10 │
|
|
493
|
+
* │ A │ 20 │
|
|
494
|
+
* │ B │ 30 │
|
|
495
|
+
* └───────┴─────┘
|
|
496
|
+
* >>> df.withColumns($df.col("val").rowNumber().over("group").alias("rn"))
|
|
497
|
+
* shape: (3, 3)
|
|
498
|
+
* ┌───────┬─────┬────┐
|
|
499
|
+
* │ group │ val │ rn │
|
|
500
|
+
* ├───────┼─────┼────┤
|
|
501
|
+
* │ A │ 10 │ 1 │
|
|
502
|
+
* │ A │ 20 │ 2 │
|
|
503
|
+
* │ B │ 30 │ 1 │
|
|
504
|
+
* └───────┴─────┴────┘
|
|
337
505
|
*/
|
|
338
|
-
|
|
506
|
+
rowNumber(): this;
|
|
339
507
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IExpr, DataFrameSchema, RegisteredDataType, ColumnData } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the DataType for an expression operand, whether it is an IExpr, a DataType, a literal value, or a column name.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveOperandType(operand: unknown, schema: DataFrameSchema): RegisteredDataType | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Deduces the output DataType of a binary arithmetic operation between two DataTypes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function deduceBinaryType(leftType: RegisteredDataType | undefined, rightType: RegisteredDataType | undefined, colSample?: ColumnData | any[]): RegisteredDataType | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the output DataType of an expression given the input DataFrame schema and evaluated column.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveExprOutputType(expr: IExpr, schema: DataFrameSchema, colSample?: ColumnData | any[]): RegisteredDataType | undefined;
|
|
@@ -6,4 +6,9 @@ export interface RandomOptions {
|
|
|
6
6
|
max?: number;
|
|
7
7
|
integer?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export type NumericArg = number | IExpr | null;
|
|
9
|
+
export type NumericArg = number | bigint | IExpr | null;
|
|
10
|
+
export interface IsCloseOptions {
|
|
11
|
+
absTol?: number;
|
|
12
|
+
relTol?: number;
|
|
13
|
+
nansEqual?: boolean;
|
|
14
|
+
}
|
|
@@ -12,3 +12,19 @@ export declare function evalBinaryOp(v: any, r: any, fn: (a: any, b: any) => any
|
|
|
12
12
|
export declare const kleeneUnary: (fn: (v: any) => any) => (vArray: ColumnData) => any[];
|
|
13
13
|
export declare const kleeneBinary: (expr: IExpr, other: any, fn: (v: any, r: any) => any) => (vArray: ColumnData, columns: ColumnDict) => any[];
|
|
14
14
|
export declare function evaluateExpression(expr: IExpr, columns: ColumnDict, height: number): ColumnData;
|
|
15
|
+
/**
|
|
16
|
+
* Evaluates a column expression, column string lookup, or returns a scalar literal value.
|
|
17
|
+
*/
|
|
18
|
+
export declare function evaluateArg(arg: unknown, columns: ColumnDict | null | undefined, height: number): any;
|
|
19
|
+
/**
|
|
20
|
+
* Determines whether an evaluated argument is an actual DataFrame column array
|
|
21
|
+
* rather than a scalar or literal array/buffer cell value.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isEvaluatedColumn(arg: unknown, evaluatedVal: unknown, columns: ColumnDict | null | undefined, height: number): boolean;
|
|
24
|
+
export declare function buildCanonicalSet(vals: any): Set<string>;
|
|
25
|
+
export declare function computeIsIn(vArray: ArrayLike<any>, columns: any, values: any): any[];
|
|
26
|
+
export declare function compareMissing(vArray: ArrayLike<any>, rResolved: any): boolean[];
|
|
27
|
+
export declare function computeRank(arr: any[], value: any, options?: {
|
|
28
|
+
ignoreNulls?: boolean;
|
|
29
|
+
dense?: boolean;
|
|
30
|
+
}): number | null;
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export declare const NEWLINE = "\n";
|
|
2
2
|
export declare const CARRIAGE_RETURN = "\r";
|
|
3
3
|
export declare const UTF8_BOM = "\uFEFF";
|
|
4
|
+
export declare const NEWLINE_PATTERN = "\\r\\n|\\n|\\r";
|
|
5
|
+
export declare const NEWLINE_REGEX: RegExp;
|
|
6
|
+
/** Reusable singleton TextEncoder instance for UTF-8 string encoding across the codebase. */
|
|
7
|
+
export declare const TEXT_ENCODER: TextEncoder;
|
|
8
|
+
/** Reusable singleton TextDecoder instances for non-fatal and fatal UTF-8 decoding. */
|
|
9
|
+
export declare const TEXT_DECODER: TextDecoder;
|
|
10
|
+
export declare const TEXT_DECODER_FATAL: TextDecoder;
|
|
4
11
|
export declare const MS_PER_WEEK = 604800000;
|
|
5
12
|
export declare const MS_PER_DAY = 86400000;
|
|
6
13
|
export declare const MS_PER_HOUR = 3600000;
|
|
@@ -13,6 +20,8 @@ export declare const US_PER_MS = 1000;
|
|
|
13
20
|
export declare const NS_PER_MS = 1000000;
|
|
14
21
|
export declare const US_PER_MS_BI = 1000n;
|
|
15
22
|
export declare const NS_PER_MS_BI = 1000000n;
|
|
23
|
+
/** Day of week string to UTC day index mapping (Sunday = 0, Saturday = 6) */
|
|
24
|
+
export declare const DAY_OF_WEEK_MAP: Readonly<Record<string, number>>;
|
|
16
25
|
/** Separates composite key segments within a single row hash (e.g. multi-column join keys). */
|
|
17
26
|
export declare const KEY_SEPARATOR = "\0";
|
|
18
27
|
/** Separates key-value pairs within a serialized object or map canonical hash. */
|
|
@@ -21,3 +30,32 @@ export declare const KEY_PAIR_SEPARATOR = "\u0001";
|
|
|
21
30
|
export declare const UNMATCHED_ROW_INDEX = -1;
|
|
22
31
|
/** Maximum allowable length for a single JavaScript array (2^32 - 1). */
|
|
23
32
|
export declare const MAX_JS_ARRAY_LENGTH = 4294967295;
|
|
33
|
+
/** 64-bit Integer Boundaries */
|
|
34
|
+
export declare const INT64_MIN = -9223372036854775808n;
|
|
35
|
+
export declare const INT64_MAX = 9223372036854775807n;
|
|
36
|
+
export declare const UINT64_MIN = 0n;
|
|
37
|
+
export declare const UINT64_MAX = 18446744073709551615n;
|
|
38
|
+
/** 32-bit & Standard Integer Boundaries */
|
|
39
|
+
export declare const INT32_MIN = -2147483648;
|
|
40
|
+
export declare const INT32_MAX = 2147483647;
|
|
41
|
+
export declare const UINT32_MIN = 0;
|
|
42
|
+
export declare const UINT32_MAX = 4294967295;
|
|
43
|
+
export declare const INT16_MIN = -32768;
|
|
44
|
+
export declare const INT16_MAX = 32767;
|
|
45
|
+
export declare const UINT16_MIN = 0;
|
|
46
|
+
export declare const UINT16_MAX = 65535;
|
|
47
|
+
export declare const INT8_MIN = -128;
|
|
48
|
+
export declare const INT8_MAX = 127;
|
|
49
|
+
export declare const UINT8_MIN = 0;
|
|
50
|
+
export declare const UINT8_MAX = 255;
|
|
51
|
+
/** Unicode Codepoint Boundaries for Control Characters & Surrogates */
|
|
52
|
+
export declare const MAX_C0_CONTROL_CODE = 31;
|
|
53
|
+
export declare const ASCII_DEL_CODE = 127;
|
|
54
|
+
export declare const SURROGATE_HIGH_MIN_CODE = 55296;
|
|
55
|
+
export declare const SURROGATE_HIGH_MAX_CODE = 56319;
|
|
56
|
+
export declare const SURROGATE_LOW_MIN_CODE = 56320;
|
|
57
|
+
export declare const SURROGATE_LOW_MAX_CODE = 57343;
|
|
58
|
+
/** Named escape mappings for common control characters */
|
|
59
|
+
export declare const NAMED_CONTROL_ESCAPES: Readonly<Record<number, string>>;
|
|
60
|
+
/** Inverse unescape mapping for control character escape sequences */
|
|
61
|
+
export declare const CONTROL_UNESCAPE_MAP: Readonly<Record<string, string>>;
|