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.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/api.d.ts +2 -1
  3. package/dist/assets/index-DBhGK6Tp.css +1 -0
  4. package/dist/assets/index-DEJEV_tU.js +195 -0
  5. package/dist/columnExpressions/ColumnExpr.d.ts +12 -5
  6. package/dist/columnExpressions/ExprBase.d.ts +26 -12
  7. package/dist/columnExpressions/constants.d.ts +1 -0
  8. package/dist/columnExpressions/functions/all.d.ts +23 -0
  9. package/dist/columnExpressions/functions/coalesce.d.ts +29 -0
  10. package/dist/columnExpressions/functions/element.d.ts +25 -0
  11. package/dist/columnExpressions/functions/exclude.d.ts +24 -0
  12. package/dist/columnExpressions/functions/implode.d.ts +28 -0
  13. package/dist/columnExpressions/functions/lit.d.ts +27 -0
  14. package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
  15. package/dist/columnExpressions/functions/struct.d.ts +31 -0
  16. package/dist/columnExpressions/functions/when.d.ts +36 -6
  17. package/dist/columnExpressions/index.d.ts +1 -0
  18. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +334 -0
  19. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +609 -0
  20. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +533 -5
  21. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
  22. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
  23. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
  24. package/dist/columnExpressions/mixins/StringExpr.d.ts +656 -3
  25. package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
  26. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +530 -4
  27. package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
  28. package/dist/columnExpressions/types.d.ts +1 -0
  29. package/dist/dataframe/dataframe.d.ts +932 -2
  30. package/dist/dataframe/grouped/grouped.d.ts +41 -6
  31. package/dist/dataframe/types.d.ts +1 -0
  32. package/dist/dataframe/utils.d.ts +1 -0
  33. package/dist/datatypes/types.d.ts +45 -0
  34. package/dist/exceptions/index.d.ts +23 -0
  35. package/dist/functions/concat.d.ts +50 -0
  36. package/dist/functions/read_csv.d.ts +9 -0
  37. package/dist/functions/read_json.d.ts +7 -2
  38. package/dist/index.html +17 -0
  39. package/dist/index.js +5 -5
  40. package/dist/index.mjs +6 -0
  41. package/dist/types.d.ts +47 -14
  42. package/dist/utils/array.d.ts +32 -1
  43. package/dist/utils/csv.d.ts +1 -0
  44. package/dist/utils/date.d.ts +10 -27
  45. package/dist/utils/json.d.ts +1 -0
  46. package/dist/utils/number.d.ts +1 -0
  47. package/dist/utils/object.d.ts +1 -0
  48. package/dist/utils/string.d.ts +12 -0
  49. package/package.json +18 -4
  50. package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
  51. package/dist/utils/guards.d.ts +0 -13
  52. package/dist/utils/list.d.ts +0 -217
@@ -1,25 +1,359 @@
1
1
  import type { AggFn, UniqueArrayStatsOptions } 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 AggregationExpr extends ExprBase {
4
9
  _deriveAgg(fn: AggFn<any>): this;
10
+ _deriveAggBinary(other: any, fn: AggFn<[any, any]>): this;
11
+ /**
12
+ * Aggregation: Returns true if all values in the group are truthy.
13
+ * @returns ColumnExpression
14
+ * @example
15
+ * >>> const df = $df.data({ group: ["A", "A", "B"], val: [true, true, false] })
16
+ * >>> df.group_by("group").agg($df.col("val").all().alias("all_true"))
17
+ * shape: (2, 2)
18
+ * ┌───────┬──────────┐
19
+ * │ group │ all_true │
20
+ * ├───────┼──────────┤
21
+ * │ "A" │ true │
22
+ * │ "B" │ false │
23
+ * └───────┴──────────┘
24
+ */
5
25
  all(): this;
26
+ /**
27
+ * Aggregation: Checks if all values in the group are null.
28
+ * @returns ColumnExpression
29
+ * @example
30
+ * >>> const df = $df.data({ group: ["A", "A"], val: [null, null] })
31
+ * >>> df.group_by("group").agg($df.col("val").all_null().alias("is_null"))
32
+ * shape: (1, 2)
33
+ * ┌───────┬─────────┐
34
+ * │ group │ is_null │
35
+ * ├───────┼─────────┤
36
+ * │ "A" │ true │
37
+ * └───────┴─────────┘
38
+ */
6
39
  all_null(): this;
40
+ /**
41
+ * Aggregation: Checks if any value in the group is truthy.
42
+ * @returns ColumnExpression
43
+ * @example
44
+ * >>> const df = $df.data({ group: ["A", "A", "B"], val: [true, false, false] })
45
+ * >>> df.group_by("group").agg($df.col("val").any().alias("any_true"))
46
+ * shape: (2, 2)
47
+ * ┌───────┬──────────┐
48
+ * │ group │ any_true │
49
+ * ├───────┼──────────┤
50
+ * │ "A" │ true │
51
+ * │ "B" │ false │
52
+ * └───────┴──────────┘
53
+ */
7
54
  any(): this;
55
+ /**
56
+ * Aggregation: Checks if any value in the group is null.
57
+ * @returns ColumnExpression
58
+ * @example
59
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, null] })
60
+ * >>> df.group_by("group").agg($df.col("val").any_null().alias("has_null"))
61
+ * shape: (1, 2)
62
+ * ┌───────┬──────────┐
63
+ * │ group │ has_null │
64
+ * ├───────┼──────────┤
65
+ * │ "A" │ true │
66
+ * └───────┴──────────┘
67
+ */
8
68
  any_null(): this;
69
+ /**
70
+ * Aggregation: Computes the arithmetic mean of the group.
71
+ * @returns ColumnExpression
72
+ * @example
73
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, 20] })
74
+ * >>> df.group_by("group").agg($df.col("val").avg().alias("mean"))
75
+ * shape: (1, 2)
76
+ * ┌───────┬──────┐
77
+ * │ group │ mean │
78
+ * ├───────┼──────┤
79
+ * │ "A" │ 15 │
80
+ * └───────┴──────┘
81
+ */
9
82
  avg(): this;
83
+ /**
84
+ * Aggregation: Computes the Pearson correlation coefficient between two columns.
85
+ * @param other The target column expression to correlate with.
86
+ * @returns ColumnExpression
87
+ * @example
88
+ * >>> const df = $df.data({ x: [1, 2, 3], y: [2, 4, 6] })
89
+ * >>> df.select($df.col("x").corr($df.col("y")).alias("correlation"))
90
+ * shape: (1, 1)
91
+ * ┌─────────────┐
92
+ * │ correlation │
93
+ * ├─────────────┤
94
+ * │ 1 │
95
+ * └─────────────┘
96
+ */
97
+ corr(other: any): this;
98
+ /**
99
+ * Aggregation: Returns the count of records inside the group.
100
+ * @param options Config flags including whether to count null values.
101
+ * @returns ColumnExpression
102
+ * @example
103
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, null] })
104
+ * >>> df.group_by("group").agg($df.col("val").count().alias("cnt"))
105
+ * shape: (1, 2)
106
+ * ┌───────┬─────┐
107
+ * │ group │ cnt │
108
+ * ├───────┼─────┤
109
+ * │ "A" │ 1 │
110
+ * └───────┴─────┘
111
+ */
10
112
  count(options?: {
11
113
  includeNulls?: boolean;
12
114
  }): this;
115
+ /**
116
+ * Aggregation: Computes the covariance between two columns.
117
+ * @param other The target column expression to compute covariance with.
118
+ * @returns ColumnExpression
119
+ * @example
120
+ * >>> const df = $df.data({ x: [1, 2, 3], y: [2, 4, 6] })
121
+ * >>> df.select($df.col("x").cov($df.col("y")).alias("covariance"))
122
+ * shape: (1, 1)
123
+ * ┌────────────┐
124
+ * │ covariance │
125
+ * ├────────────┤
126
+ * │ 2 │
127
+ * └────────────┘
128
+ */
129
+ cov(other: any): this;
130
+ /**
131
+ * Aggregation: Computes the dot product with another column.
132
+ * @param other The other column expression to compute the dot product with.
133
+ * @returns ColumnExpression
134
+ * @example
135
+ * >>> const df = $df.data({ x: [1, 2, 3], y: [2, 3, 4] })
136
+ * >>> df.select($df.col("x").dot($df.col("y")).alias("dot_product"))
137
+ * shape: (1, 1)
138
+ * ┌─────────────┐
139
+ * │ dot_product │
140
+ * ├─────────────┤
141
+ * │ 20 │
142
+ * └─────────────┘
143
+ */
144
+ dot(other: any): this;
145
+ /**
146
+ * Aggregation: Finds the first value in the group.
147
+ * @returns ColumnExpression
148
+ * @example
149
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, 20] })
150
+ * >>> df.group_by("group").agg($df.col("val").first().alias("first_val"))
151
+ * shape: (1, 2)
152
+ * ┌───────┬───────────┐
153
+ * │ group │ first_val │
154
+ * ├───────┼───────────┤
155
+ * │ "A" │ 10 │
156
+ * └───────┴───────────┘
157
+ */
13
158
  first(): this;
159
+ /**
160
+ * Aggregation: Combines all values in the group into a single array/list cell.
161
+ * @returns ColumnExpression
162
+ * @example
163
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, 20] })
164
+ * >>> df.group_by("group").agg($df.col("val").implode().alias("list_val"))
165
+ * shape: (1, 2)
166
+ * ┌───────┬──────────┐
167
+ * │ group │ list_val │
168
+ * ├───────┼──────────┤
169
+ * │ "A" │ [10, 20] │
170
+ * └───────┴──────────┘
171
+ */
14
172
  implode(): this;
173
+ /**
174
+ * Aggregation: Finds the last value in the group.
175
+ * @returns ColumnExpression
176
+ * @example
177
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, 20] })
178
+ * >>> df.group_by("group").agg($df.col("val").last().alias("last_val"))
179
+ * shape: (1, 2)
180
+ * ┌───────┬──────────┐
181
+ * │ group │ last_val │
182
+ * ├───────┼──────────┤
183
+ * │ "A" │ 20 │
184
+ * └───────┴──────────┘
185
+ */
15
186
  last(): this;
187
+ /**
188
+ * Aggregation: Finds the maximum value in the group.
189
+ * @returns ColumnExpression
190
+ * @example
191
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, 50] })
192
+ * >>> df.group_by("group").agg($df.col("val").max().alias("max_val"))
193
+ * shape: (1, 2)
194
+ * ┌───────┬─────────┐
195
+ * │ group │ max_val │
196
+ * ├───────┼─────────┤
197
+ * │ "A" │ 50 │
198
+ * └───────┴─────────┘
199
+ */
16
200
  max(): this;
201
+ /**
202
+ * Aggregation: Computes the arithmetic mean of elements in the group.
203
+ * @returns ColumnExpression
204
+ * @example
205
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, 30] })
206
+ * >>> df.group_by("group").agg($df.col("val").mean().alias("mean_val"))
207
+ * shape: (1, 2)
208
+ * ┌───────┬──────────┐
209
+ * │ group │ mean_val │
210
+ * ├───────┼──────────┤
211
+ * │ "A" │ 20 │
212
+ * └───────┴──────────┘
213
+ */
17
214
  mean(): this;
215
+ /**
216
+ * Aggregation: Computes the 50th percentile median.
217
+ * @returns ColumnExpression
218
+ * @example
219
+ * >>> const df = $df.data({ group: ["A", "A", "A"], val: [10, 50, 20] })
220
+ * >>> df.group_by("group").agg($df.col("val").median().alias("med"))
221
+ * shape: (1, 2)
222
+ * ┌───────┬─────┐
223
+ * │ group │ med │
224
+ * ├───────┼─────┤
225
+ * │ "A" │ 20 │
226
+ * └───────┴─────┘
227
+ */
18
228
  median(): this;
229
+ /**
230
+ * Aggregation: Finds the minimum value in the group.
231
+ * @returns ColumnExpression
232
+ * @example
233
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, 50] })
234
+ * >>> df.group_by("group").agg($df.col("val").min().alias("min_val"))
235
+ * shape: (1, 2)
236
+ * ┌───────┬─────────┐
237
+ * │ group │ min_val │
238
+ * ├───────┼─────────┤
239
+ * │ "A" │ 10 │
240
+ * └───────┴─────────┘
241
+ */
19
242
  min(): this;
243
+ /**
244
+ * Aggregation: Finds the statistical mode (most frequent value).
245
+ * @returns ColumnExpression
246
+ * @example
247
+ * >>> const df = $df.data({ group: ["A", "A", "A"], val: [5, 5, 10] })
248
+ * >>> df.group_by("group").agg($df.col("val").mode().alias("mode_val"))
249
+ * shape: (1, 2)
250
+ * ┌───────┬──────────┐
251
+ * │ group │ mode_val │
252
+ * ├───────┼──────────┤
253
+ * │ "A" │ 5 │
254
+ * └───────┴──────────┘
255
+ */
20
256
  mode(): this;
257
+ /**
258
+ * Aggregation: Computes number of unique elements.
259
+ * @param options Uniqueness options.
260
+ * @returns ColumnExpression
261
+ * @example
262
+ * >>> const df = $df.data({ group: ["A", "A", "A"], val: [5, 5, 10] })
263
+ * >>> df.group_by("group").agg($df.col("val").n_unique().alias("unique_cnt"))
264
+ * shape: (1, 2)
265
+ * ┌───────┬────────────┐
266
+ * │ group │ unique_cnt │
267
+ * ├───────┼────────────┤
268
+ * │ "A" │ 2 │
269
+ * └───────┴────────────┘
270
+ */
21
271
  n_unique(options?: UniqueArrayStatsOptions): this;
272
+ /**
273
+ * Aggregation: Counts the number of null or missing records.
274
+ * @returns ColumnExpression
275
+ * @example
276
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, null] })
277
+ * >>> df.group_by("group").agg($df.col("val").null_count().alias("nulls"))
278
+ * shape: (1, 2)
279
+ * ┌───────┬───────┐
280
+ * │ group │ nulls │
281
+ * ├───────┼───────┤
282
+ * │ "A" │ 1 │
283
+ * └───────┴───────┘
284
+ */
285
+ null_count(): this;
286
+ /**
287
+ * Aggregation: Computes the specific quantile values (0.0 to 1.0).
288
+ * @param q The quantile parameter value between 0.0 and 1.0.
289
+ * @returns ColumnExpression
290
+ * @example
291
+ * >>> const df = $df.data({ val: [10, 20, 30, 40] })
292
+ * >>> df.select($df.col("val").quantile(0.75).alias("q75"))
293
+ * shape: (1, 1)
294
+ * ┌─────┐
295
+ * │ q75 │
296
+ * ├─────┤
297
+ * │ 32.5│
298
+ * └─────┘
299
+ */
22
300
  quantile(q: number): this;
301
+ /**
302
+ * Aggregation: Computes the Spearman rank correlation coefficient.
303
+ * @param other The other column expression to correlate with.
304
+ * @returns ColumnExpression
305
+ * @example
306
+ * >>> const df = $df.data({ x: [1, 2, 3], y: [5, 6, 7] })
307
+ * >>> df.select($df.col("x").spearman_corr($df.col("y")).alias("spearman"))
308
+ * shape: (1, 1)
309
+ * ┌──────────┐
310
+ * │ spearman │
311
+ * ├──────────┤
312
+ * │ 1 │
313
+ * └──────────┘
314
+ */
315
+ spearman_corr(other: any): this;
316
+ /**
317
+ * Aggregation: Computes sample standard deviation.
318
+ * @returns ColumnExpression
319
+ * @example
320
+ * >>> const df = $df.data({ group: ["A", "A", "A"], val: [10, 20, 30] })
321
+ * >>> df.group_by("group").agg($df.col("val").std().alias("std_dev"))
322
+ * shape: (1, 2)
323
+ * ┌───────┬─────────┐
324
+ * │ group │ std_dev │
325
+ * ├───────┼─────────┤
326
+ * │ "A" │ 10 │
327
+ * └───────┴─────────┘
328
+ */
23
329
  std(): this;
330
+ /**
331
+ * Aggregation: Computes the sum of elements in the group.
332
+ * @returns ColumnExpression
333
+ * @example
334
+ * >>> const df = $df.data({ group: ["A", "A"], val: [10, 20] })
335
+ * >>> df.group_by("group").agg($df.col("val").sum().alias("total"))
336
+ * shape: (1, 2)
337
+ * ┌───────┬───────┐
338
+ * │ group │ total │
339
+ * ├───────┼───────┤
340
+ * │ "A" │ 30 │
341
+ * └───────┴───────┘
342
+ */
24
343
  sum(): this;
344
+ /**
345
+ * Aggregation: Computes weighted average.
346
+ * @param weights The weight values or column expression.
347
+ * @returns ColumnExpression
348
+ * @example
349
+ * >>> const df = $df.data({ val: [10, 20], weight: [1, 3] })
350
+ * >>> df.select($df.col("val").w_avg($df.col("weight")).alias("w_mean"))
351
+ * shape: (1, 1)
352
+ * ┌────────┐
353
+ * │ w_mean │
354
+ * ├────────┤
355
+ * │ 17.5 │
356
+ * └────────┘
357
+ */
358
+ w_avg(weights: any): this;
25
359
  }