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.
Files changed (59) hide show
  1. package/README.md +148 -235
  2. package/dist/api.d.ts +41 -36
  3. package/dist/columnExpressions/ColumnExpr.d.ts +5 -8
  4. package/dist/columnExpressions/functions/all.d.ts +13 -13
  5. package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
  6. package/dist/columnExpressions/functions/duration.d.ts +16 -21
  7. package/dist/columnExpressions/functions/element.d.ts +10 -10
  8. package/dist/columnExpressions/functions/exclude.d.ts +14 -14
  9. package/dist/columnExpressions/functions/implode.d.ts +7 -7
  10. package/dist/columnExpressions/functions/lit.d.ts +9 -9
  11. package/dist/columnExpressions/functions/seqRange.d.ts +69 -0
  12. package/dist/columnExpressions/functions/struct.d.ts +6 -6
  13. package/dist/columnExpressions/functions/when.d.ts +25 -28
  14. package/dist/columnExpressions/index.d.ts +3 -7
  15. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +550 -221
  16. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +701 -327
  17. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +508 -212
  18. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +398 -201
  19. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +59 -29
  20. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +23 -9
  21. package/dist/columnExpressions/mixins/StandardExpr.d.ts +3234 -0
  22. package/dist/columnExpressions/mixins/StringExpr.d.ts +1163 -524
  23. package/dist/columnExpressions/mixins/StructExpr.d.ts +67 -25
  24. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +518 -212
  25. package/dist/columnExpressions/mixins/WindowExpr.d.ts +270 -102
  26. package/dist/columnExpressions/typeInference.d.ts +3 -3
  27. package/dist/columnExpressions/types.d.ts +5 -0
  28. package/dist/columnExpressions/utils.d.ts +7 -0
  29. package/dist/constants.d.ts +11 -2
  30. package/dist/dataframe/dataframe.d.ts +755 -592
  31. package/dist/dataframe/grouped/grouped.d.ts +24 -6
  32. package/dist/dataframe/grouped.d.ts +70 -0
  33. package/dist/dataframe/index.d.ts +1 -1
  34. package/dist/dataframe/lazy.d.ts +37 -0
  35. package/dist/dataframe/types.d.ts +46 -22
  36. package/dist/dataframe/utils.d.ts +10 -4
  37. package/dist/datatypes/index.d.ts +11 -4
  38. package/dist/expressions.js +1 -0
  39. package/dist/expressions.mjs +1 -0
  40. package/dist/functions/concat.d.ts +68 -16
  41. package/dist/functions/index.d.ts +2 -2
  42. package/dist/functions/readCsv.d.ts +35 -0
  43. package/dist/functions/readJson.d.ts +33 -0
  44. package/dist/index.js +5 -6
  45. package/dist/index.mjs +5 -6
  46. package/dist/types.d.ts +42 -9
  47. package/dist/utils/array.d.ts +17 -14
  48. package/dist/utils/csv.d.ts +4 -1
  49. package/dist/utils/date.d.ts +3 -19
  50. package/dist/utils/duration.d.ts +7 -5
  51. package/dist/utils/json.d.ts +5 -3
  52. package/dist/utils/object.d.ts +0 -18
  53. package/dist/utils/string.d.ts +5 -0
  54. package/dist/utils.js +4 -0
  55. package/dist/utils.mjs +4 -0
  56. package/package.json +29 -8
  57. package/dist/assets/index-DBhGK6Tp.css +0 -1
  58. package/dist/assets/index-DEJEV_tU.js +0 -195
  59. 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
- * >>> const df = $df.data({ val: [10, 20, 30] })
20
- * >>> df.with_columns($df.col("val").cum_count().alias("c_count"))
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
- cum_count(reverse?: boolean): this;
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
- * >>> const df = $df.data({ val: [1, 3, 2] })
37
- * >>> df.with_columns($df.col("val").cum_max().alias("c_max"))
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
- * │ 1 1
43
- * │ 3 3
44
- * │ 2 3
60
+ * │ 10 10
61
+ * │ 20 20
62
+ * │ 30 30
45
63
  * └─────┴───────┘
46
64
  */
47
- cum_max(reverse?: boolean): this;
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
- * >>> const df = $df.data({ val: [3, 1, 2] })
54
- * >>> df.with_columns($df.col("val").cum_min().alias("c_min"))
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
- * │ 3 3
60
- * │ 1 1
61
- * │ 2 1
86
+ * │ 10 10
87
+ * │ 20 10
88
+ * │ 30 10
62
89
  * └─────┴───────┘
63
90
  */
64
- cum_min(reverse?: boolean): this;
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
- * >>> const df = $df.data({ val: [1, 2, 3, 4] })
71
- * >>> df.with_columns($df.col("val").cum_prod().alias("c_prod"))
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
- * │ val │ c_prod │
75
- * ├─────┼────────┤
76
- * │ 1 │ 1 │
77
- * │ 2 │ 2 │
78
- * │ 3 │ 6 │
79
- * │ 4 │ 24 │
80
- * └─────┴────────┘
109
+ * ┌───┬────────┐
110
+ * │ a │ c_prod │
111
+ * ├───┼────────┤
112
+ * │ 1 │ 1 │
113
+ * │ 2 │ 2 │
114
+ * │ 3 │ 6 │
115
+ * │ 4 │ 24 │
116
+ * └───┴────────┘
81
117
  */
82
- cum_prod(reverse?: boolean): this;
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
- * >>> const df = $df.data({ val: [10, 20, 30] })
89
- * >>> df.with_columns($df.col("val").cum_sum().alias("c_sum"))
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
- cum_sum(reverse?: boolean): this;
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
- * >>> const df = $df.data({ score: [100, 100, 90] })
105
- * >>> df.with_columns($df.col("score").dense_rank().alias("dr"))
106
- * shape: (3, 2)
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
- * │ 100 2
111
- * │ 100 │ 2 │
112
- * │ 90 │ 1 │
164
+ * │ 75 1
165
+ * │ 95 │ 2 │
113
166
  * └───────┴────┘
114
167
  */
115
- dense_rank(): this;
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
- * >>> const df = $df.data({ val: [10, 20, 30] })
123
- * >>> df.with_columns($df.col("val").lag(1, 0).alias("prev"))
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
- * >>> const df = $df.data({ val: [10, 20, 30] })
141
- * >>> df.with_columns($df.col("val").lead(1, 0).alias("next"))
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
- * >>> 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"))
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
- * │ cat │ val │ cat_sum │
162
- * ├─────┼─────┼─────────┤
163
- * │ A │ 10 │ 30 │
164
- * │ A │ 20 │ 30 │
165
- * │ B │ 30 │ 30 │
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
- * >>> const df = $df.data({ score: [100, 80, 90] })
174
- * >>> df.with_columns($df.col("score").rank().alias("rank"))
175
- * shape: (3, 2)
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
- * │ 100 3
180
- * │ 801
181
- * │ 90 │ 2 │
268
+ * │ 75 1
269
+ * │ 952
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
- * >>> 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)
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
- * │ 1 1
197
- * │ 5 5
198
- * │ 2 5
199
- * │ 8 │ 8 │
293
+ * │ 10 10
294
+ * │ 20 20
295
+ * │ 30 30
200
296
  * └─────┴───────┘
201
297
  */
202
- rolling_max(windowSize: number): this;
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
- * >>> const df = $df.data({ val: [10, 20, 30] })
209
- * >>> df.with_columns($df.col("val").rolling_mean(2).alias("r_mean"))
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
- rolling_mean(windowSize: number): this;
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
- * >>> const df = $df.data({ val: [10, 30, 20] })
226
- * >>> df.with_columns($df.col("val").rolling_median(2).alias("r_med"))
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
- * │ 3020
233
- * │ 20 │ 25 │
346
+ * │ 2015
347
+ * │ 30 │ 25 │
234
348
  * └─────┴───────┘
235
349
  */
236
- rolling_median(windowSize: number): this;
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
- * >>> const df = $df.data({ val: [10, 5, 20] })
243
- * >>> df.with_columns($df.col("val").rolling_min(2).alias("r_min"))
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
- * │ 5 5
250
- * │ 205
372
+ * │ 20 10
373
+ * │ 3020
251
374
  * └─────┴───────┘
252
375
  */
253
- rolling_min(windowSize: number): this;
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
- * >>> const df = $df.data({ val: [10, 20, 30] })
261
- * >>> df.with_columns($df.col("val").rolling_quantile(0.5, 2).alias("r_quant"))
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
- rolling_quantile(quantile: number, windowSize: number): this;
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
- * >>> const df = $df.data({ val: [10, 20, 15] })
278
- * >>> df.with_columns($df.col("val").rolling_rank(2).alias("r_rank"))
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
- * │ 151
426
+ * │ 302
286
427
  * └─────┴────────┘
287
428
  */
288
- rolling_rank(windowSize: number): this;
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
- * >>> const df = $df.data({ val: [10, 20, 30] })
295
- * >>> df.with_columns($df.col("val").rolling_std(2).alias("r_std"))
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
- rolling_std(windowSize: number): this;
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
- * >>> const df = $df.data({ val: [10, 20, 30] })
312
- * >>> df.with_columns($df.col("val").rolling_sum(2).alias("r_sum"))
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
- rolling_sum(windowSize: number): this;
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
- * >>> 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
- * │ catrn
332
- * ├─────┼────┤
333
- * │ A 1
334
- * │ A 2
335
- * │ B 1
336
- * └─────┴────┘
486
+ * >>> const df = $df.data({ group: ["A", "A", "B"], val: [10, 20, 30] })
487
+ * >>> df
488
+ * shape: (3, 2)
489
+ * ┌───────┬─────┐
490
+ * │ groupval
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
- row_number(): this;
506
+ rowNumber(): this;
339
507
  }
@@ -1,4 +1,4 @@
1
- import type { IExpr, DataFrameSchema, RegisteredDataType } from "../types";
1
+ import type { IExpr, DataFrameSchema, RegisteredDataType, ColumnData } from "../types";
2
2
  /**
3
3
  * Resolves the DataType for an expression operand, whether it is an IExpr, a DataType, a literal value, or a column name.
4
4
  */
@@ -6,8 +6,8 @@ export declare function resolveOperandType(operand: unknown, schema: DataFrameSc
6
6
  /**
7
7
  * Deduces the output DataType of a binary arithmetic operation between two DataTypes.
8
8
  */
9
- export declare function deduceBinaryType(leftType: RegisteredDataType | undefined, rightType: RegisteredDataType | undefined, colSample?: any[]): RegisteredDataType | undefined;
9
+ export declare function deduceBinaryType(leftType: RegisteredDataType | undefined, rightType: RegisteredDataType | undefined, colSample?: ColumnData | any[]): RegisteredDataType | undefined;
10
10
  /**
11
11
  * Resolves the output DataType of an expression given the input DataFrame schema and evaluated column.
12
12
  */
13
- export declare function resolveExprOutputType(expr: IExpr, schema: DataFrameSchema, colSample?: any[]): RegisteredDataType | undefined;
13
+ export declare function resolveExprOutputType(expr: IExpr, schema: DataFrameSchema, colSample?: ColumnData | any[]): RegisteredDataType | undefined;
@@ -7,3 +7,8 @@ export interface RandomOptions {
7
7
  integer?: boolean;
8
8
  }
9
9
  export type NumericArg = number | bigint | IExpr | null;
10
+ export interface IsCloseOptions {
11
+ absTol?: number;
12
+ relTol?: number;
13
+ nansEqual?: boolean;
14
+ }
@@ -21,3 +21,10 @@ export declare function evaluateArg(arg: unknown, columns: ColumnDict | null | u
21
21
  * rather than a scalar or literal array/buffer cell value.
22
22
  */
23
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;
@@ -1,8 +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;
4
6
  /** Reusable singleton TextEncoder instance for UTF-8 string encoding across the codebase. */
5
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;
6
11
  export declare const MS_PER_WEEK = 604800000;
7
12
  export declare const MS_PER_DAY = 86400000;
8
13
  export declare const MS_PER_HOUR = 3600000;
@@ -15,6 +20,8 @@ export declare const US_PER_MS = 1000;
15
20
  export declare const NS_PER_MS = 1000000;
16
21
  export declare const US_PER_MS_BI = 1000n;
17
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>>;
18
25
  /** Separates composite key segments within a single row hash (e.g. multi-column join keys). */
19
26
  export declare const KEY_SEPARATOR = "\0";
20
27
  /** Separates key-value pairs within a serialized object or map canonical hash. */
@@ -44,8 +51,10 @@ export declare const UINT8_MAX = 255;
44
51
  /** Unicode Codepoint Boundaries for Control Characters & Surrogates */
45
52
  export declare const MAX_C0_CONTROL_CODE = 31;
46
53
  export declare const ASCII_DEL_CODE = 127;
47
- export declare const SURROGATE_MIN_CODE = 55296;
48
- export declare const SURROGATE_MAX_CODE = 57343;
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;
49
58
  /** Named escape mappings for common control characters */
50
59
  export declare const NAMED_CONTROL_ESCAPES: Readonly<Record<number, string>>;
51
60
  /** Inverse unescape mapping for control character escape sequences */