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,28 +1,339 @@
|
|
|
1
1
|
import type { IExpr } from "../../types";
|
|
2
2
|
import { ExprBase } from "../ExprBase";
|
|
3
|
+
/**
|
|
4
|
+
* @namespace $df.col
|
|
5
|
+
* @category ColumnExpression
|
|
6
|
+
* @syntax $df.col(<column_name>).{symbol}(...)
|
|
7
|
+
*/
|
|
3
8
|
export declare class WindowExpr extends ExprBase {
|
|
4
|
-
|
|
9
|
+
_partitionBy: (string | IExpr)[] | null;
|
|
5
10
|
_window(evaluateWindow: (this: IExpr, groupPreValues: any[], partitionIndices: number[], currentIndex: number) => any): this;
|
|
6
11
|
_rolling(windowSize: number, aggFn: (vals: any[]) => any): this;
|
|
7
12
|
_cum(reverse: boolean, initialVal: any, stepFn: (acc: any, val: any) => any, postFn?: (acc: any, hasValid: boolean) => any): this;
|
|
8
|
-
get
|
|
13
|
+
get _isWindow(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Window: Computes cumulative count.
|
|
16
|
+
* @param reverse Flag indicating whether to compute from reverse direction.
|
|
17
|
+
* @returns ColumnExpression
|
|
18
|
+
* @example
|
|
19
|
+
* >>> const df = $df.data({ val: [10, 20, 30] })
|
|
20
|
+
* >>> df.with_columns($df.col("val").cum_count().alias("c_count"))
|
|
21
|
+
* shape: (3, 2)
|
|
22
|
+
* ┌─────┬─────────┐
|
|
23
|
+
* │ val │ c_count │
|
|
24
|
+
* ├─────┼─────────┤
|
|
25
|
+
* │ 10 │ 1 │
|
|
26
|
+
* │ 20 │ 2 │
|
|
27
|
+
* │ 30 │ 3 │
|
|
28
|
+
* └─────┴─────────┘
|
|
29
|
+
*/
|
|
9
30
|
cum_count(reverse?: boolean): this;
|
|
31
|
+
/**
|
|
32
|
+
* Window: Computes cumulative maximum value.
|
|
33
|
+
* @param reverse Flag indicating whether to compute in reverse direction.
|
|
34
|
+
* @returns ColumnExpression
|
|
35
|
+
* @example
|
|
36
|
+
* >>> const df = $df.data({ val: [1, 3, 2] })
|
|
37
|
+
* >>> df.with_columns($df.col("val").cum_max().alias("c_max"))
|
|
38
|
+
* shape: (3, 2)
|
|
39
|
+
* ┌─────┬───────┐
|
|
40
|
+
* │ val │ c_max │
|
|
41
|
+
* ├─────┼───────┤
|
|
42
|
+
* │ 1 │ 1 │
|
|
43
|
+
* │ 3 │ 3 │
|
|
44
|
+
* │ 2 │ 3 │
|
|
45
|
+
* └─────┴───────┘
|
|
46
|
+
*/
|
|
10
47
|
cum_max(reverse?: boolean): this;
|
|
48
|
+
/**
|
|
49
|
+
* Window: Computes cumulative minimum value.
|
|
50
|
+
* @param reverse Flag indicating whether to compute in reverse direction.
|
|
51
|
+
* @returns ColumnExpression
|
|
52
|
+
* @example
|
|
53
|
+
* >>> const df = $df.data({ val: [3, 1, 2] })
|
|
54
|
+
* >>> df.with_columns($df.col("val").cum_min().alias("c_min"))
|
|
55
|
+
* shape: (3, 2)
|
|
56
|
+
* ┌─────┬───────┐
|
|
57
|
+
* │ val │ c_min │
|
|
58
|
+
* ├─────┼───────┤
|
|
59
|
+
* │ 3 │ 3 │
|
|
60
|
+
* │ 1 │ 1 │
|
|
61
|
+
* │ 2 │ 1 │
|
|
62
|
+
* └─────┴───────┘
|
|
63
|
+
*/
|
|
11
64
|
cum_min(reverse?: boolean): this;
|
|
65
|
+
/**
|
|
66
|
+
* Window: Computes cumulative product of values.
|
|
67
|
+
* @param reverse Flag indicating whether to compute in reverse direction.
|
|
68
|
+
* @returns ColumnExpression
|
|
69
|
+
* @example
|
|
70
|
+
* >>> const df = $df.data({ val: [1, 2, 3, 4] })
|
|
71
|
+
* >>> df.with_columns($df.col("val").cum_prod().alias("c_prod"))
|
|
72
|
+
* shape: (4, 2)
|
|
73
|
+
* ┌─────┬────────┐
|
|
74
|
+
* │ val │ c_prod │
|
|
75
|
+
* ├─────┼────────┤
|
|
76
|
+
* │ 1 │ 1 │
|
|
77
|
+
* │ 2 │ 2 │
|
|
78
|
+
* │ 3 │ 6 │
|
|
79
|
+
* │ 4 │ 24 │
|
|
80
|
+
* └─────┴────────┘
|
|
81
|
+
*/
|
|
12
82
|
cum_prod(reverse?: boolean): this;
|
|
83
|
+
/**
|
|
84
|
+
* Window: Computes cumulative sum of values.
|
|
85
|
+
* @param reverse Flag indicating whether to compute in reverse direction.
|
|
86
|
+
* @returns ColumnExpression
|
|
87
|
+
* @example
|
|
88
|
+
* >>> const df = $df.data({ val: [10, 20, 30] })
|
|
89
|
+
* >>> df.with_columns($df.col("val").cum_sum().alias("c_sum"))
|
|
90
|
+
* shape: (3, 2)
|
|
91
|
+
* ┌─────┬───────┐
|
|
92
|
+
* │ val │ c_sum │
|
|
93
|
+
* ├─────┼───────┤
|
|
94
|
+
* │ 10 │ 10 │
|
|
95
|
+
* │ 20 │ 30 │
|
|
96
|
+
* │ 30 │ 60 │
|
|
97
|
+
* └─────┴───────┘
|
|
98
|
+
*/
|
|
13
99
|
cum_sum(reverse?: boolean): this;
|
|
100
|
+
/**
|
|
101
|
+
* Window: Computes dense rank (ranks without gaps) within group partition.
|
|
102
|
+
* @returns ColumnExpression
|
|
103
|
+
* @example
|
|
104
|
+
* >>> const df = $df.data({ score: [100, 100, 90] })
|
|
105
|
+
* >>> df.with_columns($df.col("score").dense_rank().alias("dr"))
|
|
106
|
+
* shape: (3, 2)
|
|
107
|
+
* ┌───────┬────┐
|
|
108
|
+
* │ score │ dr │
|
|
109
|
+
* ├───────┼────┤
|
|
110
|
+
* │ 100 │ 2 │
|
|
111
|
+
* │ 100 │ 2 │
|
|
112
|
+
* │ 90 │ 1 │
|
|
113
|
+
* └───────┴────┘
|
|
114
|
+
*/
|
|
14
115
|
dense_rank(): this;
|
|
116
|
+
/**
|
|
117
|
+
* Window: Shifts values down by offset, filling missing slots with default value.
|
|
118
|
+
* @param offset Number of rows to shift down (default 1).
|
|
119
|
+
* @param defaultVal Fallback fill value for empty slots (default null).
|
|
120
|
+
* @returns ColumnExpression
|
|
121
|
+
* @example
|
|
122
|
+
* >>> const df = $df.data({ val: [10, 20, 30] })
|
|
123
|
+
* >>> df.with_columns($df.col("val").lag(1, 0).alias("prev"))
|
|
124
|
+
* shape: (3, 2)
|
|
125
|
+
* ┌─────┬──────┐
|
|
126
|
+
* │ val │ prev │
|
|
127
|
+
* ├─────┼──────┤
|
|
128
|
+
* │ 10 │ 0 │
|
|
129
|
+
* │ 20 │ 10 │
|
|
130
|
+
* │ 30 │ 20 │
|
|
131
|
+
* └─────┴──────┘
|
|
132
|
+
*/
|
|
15
133
|
lag(offset?: number, defaultVal?: any): this;
|
|
134
|
+
/**
|
|
135
|
+
* Window: Shifts values up by offset, filling missing slots with default value.
|
|
136
|
+
* @param offset Number of rows to shift up (default 1).
|
|
137
|
+
* @param defaultVal Fallback fill value for empty slots (default null).
|
|
138
|
+
* @returns ColumnExpression
|
|
139
|
+
* @example
|
|
140
|
+
* >>> const df = $df.data({ val: [10, 20, 30] })
|
|
141
|
+
* >>> df.with_columns($df.col("val").lead(1, 0).alias("next"))
|
|
142
|
+
* shape: (3, 2)
|
|
143
|
+
* ┌─────┬──────┐
|
|
144
|
+
* │ val │ next │
|
|
145
|
+
* ├─────┼──────┤
|
|
146
|
+
* │ 10 │ 20 │
|
|
147
|
+
* │ 20 │ 30 │
|
|
148
|
+
* │ 30 │ 0 │
|
|
149
|
+
* └─────┴──────┘
|
|
150
|
+
*/
|
|
16
151
|
lead(offset?: number, defaultVal?: any): this;
|
|
152
|
+
/**
|
|
153
|
+
* Executes a window aggregation partitioned by column keys.
|
|
154
|
+
* @param columns Column expression or array of columns to partition by.
|
|
155
|
+
* @returns ColumnExpression
|
|
156
|
+
* @example
|
|
157
|
+
* >>> const df = $df.data({ cat: ["A", "A", "B"], val: [10, 20, 30] })
|
|
158
|
+
* >>> df.with_columns($df.col("val").sum().over("cat").alias("cat_sum"))
|
|
159
|
+
* shape: (3, 3)
|
|
160
|
+
* ┌─────┬─────┬─────────┐
|
|
161
|
+
* │ cat │ val │ cat_sum │
|
|
162
|
+
* ├─────┼─────┼─────────┤
|
|
163
|
+
* │ A │ 10 │ 30 │
|
|
164
|
+
* │ A │ 20 │ 30 │
|
|
165
|
+
* │ B │ 30 │ 30 │
|
|
166
|
+
* └─────┴─────┴─────────┘
|
|
167
|
+
*/
|
|
17
168
|
over(columns: string | IExpr | (string | IExpr)[]): this;
|
|
169
|
+
/**
|
|
170
|
+
* Window: Computes rank within group partition.
|
|
171
|
+
* @returns ColumnExpression
|
|
172
|
+
* @example
|
|
173
|
+
* >>> const df = $df.data({ score: [100, 80, 90] })
|
|
174
|
+
* >>> df.with_columns($df.col("score").rank().alias("rank"))
|
|
175
|
+
* shape: (3, 2)
|
|
176
|
+
* ┌───────┬──────┐
|
|
177
|
+
* │ score │ rank │
|
|
178
|
+
* ├───────┼──────┤
|
|
179
|
+
* │ 100 │ 3 │
|
|
180
|
+
* │ 80 │ 1 │
|
|
181
|
+
* │ 90 │ 2 │
|
|
182
|
+
* └───────┴──────┘
|
|
183
|
+
*/
|
|
18
184
|
rank(): this;
|
|
185
|
+
/**
|
|
186
|
+
* Window: Computes rolling window maximum value.
|
|
187
|
+
* @param windowSize Size of rolling window.
|
|
188
|
+
* @returns ColumnExpression
|
|
189
|
+
* @example
|
|
190
|
+
* >>> const df = $df.data({ val: [1, 5, 2, 8] })
|
|
191
|
+
* >>> df.with_columns($df.col("val").rolling_max(2).alias("r_max"))
|
|
192
|
+
* shape: (4, 2)
|
|
193
|
+
* ┌─────┬───────┐
|
|
194
|
+
* │ val │ r_max │
|
|
195
|
+
* ├─────┼───────┤
|
|
196
|
+
* │ 1 │ 1 │
|
|
197
|
+
* │ 5 │ 5 │
|
|
198
|
+
* │ 2 │ 5 │
|
|
199
|
+
* │ 8 │ 8 │
|
|
200
|
+
* └─────┴───────┘
|
|
201
|
+
*/
|
|
19
202
|
rolling_max(windowSize: number): this;
|
|
203
|
+
/**
|
|
204
|
+
* Window: Computes rolling window mean average.
|
|
205
|
+
* @param windowSize Size of rolling window.
|
|
206
|
+
* @returns ColumnExpression
|
|
207
|
+
* @example
|
|
208
|
+
* >>> const df = $df.data({ val: [10, 20, 30] })
|
|
209
|
+
* >>> df.with_columns($df.col("val").rolling_mean(2).alias("r_mean"))
|
|
210
|
+
* shape: (3, 2)
|
|
211
|
+
* ┌─────┬────────┐
|
|
212
|
+
* │ val │ r_mean │
|
|
213
|
+
* ├─────┼────────┤
|
|
214
|
+
* │ 10 │ 10 │
|
|
215
|
+
* │ 20 │ 15 │
|
|
216
|
+
* │ 30 │ 25 │
|
|
217
|
+
* └─────┴────────┘
|
|
218
|
+
*/
|
|
20
219
|
rolling_mean(windowSize: number): this;
|
|
220
|
+
/**
|
|
221
|
+
* Window: Computes rolling window median value.
|
|
222
|
+
* @param windowSize Size of rolling window.
|
|
223
|
+
* @returns ColumnExpression
|
|
224
|
+
* @example
|
|
225
|
+
* >>> const df = $df.data({ val: [10, 30, 20] })
|
|
226
|
+
* >>> df.with_columns($df.col("val").rolling_median(2).alias("r_med"))
|
|
227
|
+
* shape: (3, 2)
|
|
228
|
+
* ┌─────┬───────┐
|
|
229
|
+
* │ val │ r_med │
|
|
230
|
+
* ├─────┼───────┤
|
|
231
|
+
* │ 10 │ 10 │
|
|
232
|
+
* │ 30 │ 20 │
|
|
233
|
+
* │ 20 │ 25 │
|
|
234
|
+
* └─────┴───────┘
|
|
235
|
+
*/
|
|
21
236
|
rolling_median(windowSize: number): this;
|
|
237
|
+
/**
|
|
238
|
+
* Window: Computes rolling window minimum value.
|
|
239
|
+
* @param windowSize Size of rolling window.
|
|
240
|
+
* @returns ColumnExpression
|
|
241
|
+
* @example
|
|
242
|
+
* >>> const df = $df.data({ val: [10, 5, 20] })
|
|
243
|
+
* >>> df.with_columns($df.col("val").rolling_min(2).alias("r_min"))
|
|
244
|
+
* shape: (3, 2)
|
|
245
|
+
* ┌─────┬───────┐
|
|
246
|
+
* │ val │ r_min │
|
|
247
|
+
* ├─────┼───────┤
|
|
248
|
+
* │ 10 │ 10 │
|
|
249
|
+
* │ 5 │ 5 │
|
|
250
|
+
* │ 20 │ 5 │
|
|
251
|
+
* └─────┴───────┘
|
|
252
|
+
*/
|
|
22
253
|
rolling_min(windowSize: number): this;
|
|
254
|
+
/**
|
|
255
|
+
* Window: Computes rolling window quantile value.
|
|
256
|
+
* @param quantile Quantile boundary between 0.0 and 1.0.
|
|
257
|
+
* @param windowSize Size of rolling window.
|
|
258
|
+
* @returns ColumnExpression
|
|
259
|
+
* @example
|
|
260
|
+
* >>> const df = $df.data({ val: [10, 20, 30] })
|
|
261
|
+
* >>> df.with_columns($df.col("val").rolling_quantile(0.5, 2).alias("r_quant"))
|
|
262
|
+
* shape: (3, 2)
|
|
263
|
+
* ┌─────┬─────────┐
|
|
264
|
+
* │ val │ r_quant │
|
|
265
|
+
* ├─────┼─────────┤
|
|
266
|
+
* │ 10 │ 10 │
|
|
267
|
+
* │ 20 │ 15 │
|
|
268
|
+
* │ 30 │ 25 │
|
|
269
|
+
* └─────┴─────────┘
|
|
270
|
+
*/
|
|
23
271
|
rolling_quantile(quantile: number, windowSize: number): this;
|
|
272
|
+
/**
|
|
273
|
+
* Window: Computes rolling window rank.
|
|
274
|
+
* @param windowSize Size of rolling window.
|
|
275
|
+
* @returns ColumnExpression
|
|
276
|
+
* @example
|
|
277
|
+
* >>> const df = $df.data({ val: [10, 20, 15] })
|
|
278
|
+
* >>> df.with_columns($df.col("val").rolling_rank(2).alias("r_rank"))
|
|
279
|
+
* shape: (3, 2)
|
|
280
|
+
* ┌─────┬────────┐
|
|
281
|
+
* │ val │ r_rank │
|
|
282
|
+
* ├─────┼────────┤
|
|
283
|
+
* │ 10 │ 1 │
|
|
284
|
+
* │ 20 │ 2 │
|
|
285
|
+
* │ 15 │ 1 │
|
|
286
|
+
* └─────┴────────┘
|
|
287
|
+
*/
|
|
24
288
|
rolling_rank(windowSize: number): this;
|
|
289
|
+
/**
|
|
290
|
+
* Window: Computes rolling window standard deviation.
|
|
291
|
+
* @param windowSize Size of rolling window.
|
|
292
|
+
* @returns ColumnExpression
|
|
293
|
+
* @example
|
|
294
|
+
* >>> const df = $df.data({ val: [10, 20, 30] })
|
|
295
|
+
* >>> df.with_columns($df.col("val").rolling_std(2).alias("r_std"))
|
|
296
|
+
* shape: (3, 2)
|
|
297
|
+
* ┌─────┬────────┐
|
|
298
|
+
* │ val │ r_std │
|
|
299
|
+
* ├─────┼────────┤
|
|
300
|
+
* │ 10 │ 0 │
|
|
301
|
+
* │ 20 │ 7.071 │
|
|
302
|
+
* │ 30 │ 7.071 │
|
|
303
|
+
* └─────┴────────┘
|
|
304
|
+
*/
|
|
25
305
|
rolling_std(windowSize: number): this;
|
|
306
|
+
/**
|
|
307
|
+
* Window: Computes rolling window sum.
|
|
308
|
+
* @param windowSize Size of rolling window.
|
|
309
|
+
* @returns ColumnExpression
|
|
310
|
+
* @example
|
|
311
|
+
* >>> const df = $df.data({ val: [10, 20, 30] })
|
|
312
|
+
* >>> df.with_columns($df.col("val").rolling_sum(2).alias("r_sum"))
|
|
313
|
+
* shape: (3, 2)
|
|
314
|
+
* ┌─────┬───────┐
|
|
315
|
+
* │ val │ r_sum │
|
|
316
|
+
* ├─────┼───────┤
|
|
317
|
+
* │ 10 │ 10 │
|
|
318
|
+
* │ 20 │ 30 │
|
|
319
|
+
* │ 30 │ 50 │
|
|
320
|
+
* └─────┴───────┘
|
|
321
|
+
*/
|
|
26
322
|
rolling_sum(windowSize: number): this;
|
|
323
|
+
/**
|
|
324
|
+
* Window: Computes 1-indexed row number count within group partitions.
|
|
325
|
+
* @returns ColumnExpression
|
|
326
|
+
* @example
|
|
327
|
+
* >>> const df = $df.data({ cat: ["A", "A", "B"] })
|
|
328
|
+
* >>> df.with_columns($df.col("cat").row_number().over("cat").alias("rn"))
|
|
329
|
+
* shape: (3, 2)
|
|
330
|
+
* ┌─────┬────┐
|
|
331
|
+
* │ cat │ rn │
|
|
332
|
+
* ├─────┼────┤
|
|
333
|
+
* │ A │ 1 │
|
|
334
|
+
* │ A │ 2 │
|
|
335
|
+
* │ B │ 1 │
|
|
336
|
+
* └─────┴────┘
|
|
337
|
+
*/
|
|
27
338
|
row_number(): this;
|
|
28
339
|
}
|