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.
Files changed (64) hide show
  1. package/README.md +153 -203
  2. package/dist/api.d.ts +41 -36
  3. package/dist/columnExpressions/ColumnExpr.d.ts +5 -8
  4. package/dist/columnExpressions/ExprBase.d.ts +7 -0
  5. package/dist/columnExpressions/constants.d.ts +1 -0
  6. package/dist/columnExpressions/functions/all.d.ts +13 -13
  7. package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
  8. package/dist/columnExpressions/functions/duration.d.ts +16 -21
  9. package/dist/columnExpressions/functions/element.d.ts +10 -10
  10. package/dist/columnExpressions/functions/exclude.d.ts +14 -14
  11. package/dist/columnExpressions/functions/implode.d.ts +7 -7
  12. package/dist/columnExpressions/functions/lit.d.ts +9 -9
  13. package/dist/columnExpressions/functions/seqRange.d.ts +69 -0
  14. package/dist/columnExpressions/functions/struct.d.ts +6 -6
  15. package/dist/columnExpressions/functions/when.d.ts +31 -32
  16. package/dist/columnExpressions/index.d.ts +4 -7
  17. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +672 -141
  18. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +701 -327
  19. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +543 -231
  20. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +398 -201
  21. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +59 -29
  22. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +23 -9
  23. package/dist/columnExpressions/mixins/StandardExpr.d.ts +3234 -0
  24. package/dist/columnExpressions/mixins/StringExpr.d.ts +1299 -396
  25. package/dist/columnExpressions/mixins/StructExpr.d.ts +72 -30
  26. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +518 -212
  27. package/dist/columnExpressions/mixins/WindowExpr.d.ts +270 -102
  28. package/dist/columnExpressions/typeInference.d.ts +13 -0
  29. package/dist/columnExpressions/types.d.ts +6 -1
  30. package/dist/columnExpressions/utils.d.ts +16 -0
  31. package/dist/constants.d.ts +38 -0
  32. package/dist/dataframe/dataframe.d.ts +755 -608
  33. package/dist/dataframe/grouped/grouped.d.ts +24 -6
  34. package/dist/dataframe/grouped.d.ts +70 -0
  35. package/dist/dataframe/index.d.ts +1 -1
  36. package/dist/dataframe/lazy.d.ts +37 -0
  37. package/dist/dataframe/types.d.ts +46 -22
  38. package/dist/dataframe/utils.d.ts +10 -4
  39. package/dist/datatypes/index.d.ts +11 -4
  40. package/dist/expressions.js +1 -0
  41. package/dist/expressions.mjs +1 -0
  42. package/dist/functions/concat.d.ts +68 -16
  43. package/dist/functions/index.d.ts +2 -2
  44. package/dist/functions/readCsv.d.ts +35 -0
  45. package/dist/functions/readJson.d.ts +33 -0
  46. package/dist/index.js +5 -6
  47. package/dist/index.mjs +5 -6
  48. package/dist/types.d.ts +148 -7
  49. package/dist/utils/array.d.ts +54 -18
  50. package/dist/utils/binary.d.ts +6 -2
  51. package/dist/utils/csv.d.ts +4 -1
  52. package/dist/utils/date.d.ts +3 -19
  53. package/dist/utils/duration.d.ts +7 -5
  54. package/dist/utils/json.d.ts +56 -2
  55. package/dist/utils/number.d.ts +5 -2
  56. package/dist/utils/object.d.ts +7 -12
  57. package/dist/utils/string.d.ts +83 -2
  58. package/dist/utils/table.d.ts +76 -0
  59. package/dist/utils.js +4 -0
  60. package/dist/utils.mjs +4 -0
  61. package/package.json +29 -8
  62. package/dist/assets/index-DBhGK6Tp.css +0 -1
  63. package/dist/assets/index-DEJEV_tU.js +0 -195
  64. package/dist/index.html +0 -17
@@ -1,6 +1,6 @@
1
- import { GroupedData } from "./grouped/grouped";
1
+ import { GroupedData } from "./grouped";
2
2
  import type { IExpr, ColumnData, ColumnDict, DataFrameColumns, ConcatOptions, ConcatItem, HorizontalConcatOptions, RowRecord, DataFrameSchema, RegisteredDataType, ExplodeOptions, IntoExpr, FillNullOptions } from "../types";
3
- import type { LimitOptions, SortOptions, PivotOptions, JoinOptions, AsofJoinOptions, UnpivotOptions, TransposeOptions, WriteJSONOptions, WriteCSVOptions } from "./types";
3
+ import type { LimitOptions, SortOptions, PivotOptions, JoinOptions, JoinAsofOptions, JoinWhereOptions, GroupByDynamicOptions, UnpivotOptions, TransposeOptions, WriteJSONOptions, WriteCSVOptions } from "./types";
4
4
  /**
5
5
  * Two-dimensional columnar tabular data structure supporting expression execution and reshaping.
6
6
  */
@@ -29,20 +29,47 @@ export declare class DataFrame<T extends RowRecord = any> {
29
29
  * └─────┴─────┘
30
30
  */
31
31
  constructor(data: T[] | ColumnDict, schema?: DataFrameSchema, height?: number);
32
- private _inferSchema;
33
32
  private _applySchema;
33
+ private _inferSchema;
34
+ private _normalizeArgs;
34
35
  /**
35
- * Gets array of column names in the DataFrame.
36
- * @returns Array of column name strings.
36
+ * Creates a deep copy of the current DataFrame instance, duplicating all underlying column data arrays and schema metadata.
37
+ * Modifying columns or values in the cloned DataFrame will not mutate the original.
38
+ * @returns {DataFrame<T>}
37
39
  * @example
38
- * >>> const df = $df.data({ a: [1], b: [2] })
39
- * >>> df
40
- * shape: (1, 2)
40
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
41
+ * >>> df
42
+ * shape: (2, 2)
43
+ * ┌───┬───┐
44
+ * │ a │ b │
45
+ * ├───┼───┤
46
+ * │ 1 │ x │
47
+ * │ 2 │ y │
48
+ * └───┴───┘
49
+ * >>> const cloned = df.clone()
50
+ * >>> cloned
51
+ * shape: (2, 2)
41
52
  * ┌───┬───┐
42
53
  * │ a │ b │
43
54
  * ├───┼───┤
44
- * │ 1 │ 2
55
+ * │ 1 │ x
56
+ * │ 2 │ y │
45
57
  * └───┴───┘
58
+ */
59
+ clone(): DataFrame<T>;
60
+ /**
61
+ * Gets array of column names in the DataFrame.
62
+ * @returns Array of column name strings.
63
+ * @example
64
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
65
+ * >>> df
66
+ * shape: (2, 2)
67
+ * ┌───┬───┐
68
+ * │ a │ b │
69
+ * ├───┼───┤
70
+ * │ 1 │ x │
71
+ * │ 2 │ y │
72
+ * └───┴───┘
46
73
  * >>> df.columns
47
74
  * ["a", "b"]
48
75
  */
@@ -58,49 +85,94 @@ export declare class DataFrame<T extends RowRecord = any> {
58
85
  *
59
86
  * @example
60
87
  * // 1. Vertical Concatenation (default):
61
- * >>> const df1 = $df.data({ a: [1] })
62
- * >>> df1
63
- * shape: (1, 1)
64
- * ┌───┐
65
- * │ a │
66
- * ├───┤
67
- * │ 1 │
68
- * └───┘
69
- * >>> const df2 = $df.data({ a: [2] })
88
+ * >>> const df1 = $df.data({ a: [1, 2] })
89
+ * >>> const df2 = $df.data({ b: [10, 20] })
90
+ * >>> df1
91
+ * shape: (2, 1)
92
+ * ┌───┐
93
+ * │ a │
94
+ * ├───┤
95
+ * │ 1 │
96
+ * 2
97
+ * └───┘
98
+ * >>> df2
99
+ * shape: (2, 1)
100
+ * ┌────┐
101
+ * │ b │
102
+ * ├────┤
103
+ * │ 10 │
104
+ * │ 20 │
105
+ * └────┘
70
106
  * >>> df1.concat(df2, { how: "vertical" })
71
- * shape: (2, 1)
72
- * ┌───┐
73
- * │ a
74
- * ├───┤
75
- * │ 1
76
- * │ 2
77
- * └───┘
107
+ * shape: (4, 1)
108
+ * ┌──────┐
109
+ * │ a
110
+ * ├──────┤
111
+ * │ 1
112
+ * │ 2
113
+ * │ null │
114
+ * │ null │
115
+ * └──────┘
78
116
  *
79
117
  * @example
80
118
  * // 2. Horizontal Concatenation:
81
- * >>> const df1 = $df.data({ a: [1] })
82
- * >>> const df2 = $df.data({ b: [2] })
119
+ * >>> const df1 = $df.data({ a: [1, 2] })
120
+ * >>> const df2 = $df.data({ b: [10, 20] })
121
+ * >>> df1
122
+ * shape: (2, 1)
123
+ * ┌───┐
124
+ * │ a │
125
+ * ├───┤
126
+ * │ 1 │
127
+ * │ 2 │
128
+ * └───┘
129
+ * >>> df2
130
+ * shape: (2, 1)
131
+ * ┌────┐
132
+ * │ b │
133
+ * ├────┤
134
+ * │ 10 │
135
+ * │ 20 │
136
+ * └────┘
83
137
  * >>> df1.concat(df2, { how: "horizontal" })
84
- * shape: (1, 2)
85
- * ┌───┬───┐
86
- * │ a │ b
87
- * ├───┼───┤
88
- * │ 1 │ 2
89
- * └───┴───┘
138
+ * shape: (2, 2)
139
+ * ┌───┬────┐
140
+ * │ a │ b
141
+ * ├───┼────┤
142
+ * │ 1 │ 10
143
+ * │ 2 │ 20 │
144
+ * └───┴────┘
90
145
  *
91
146
  * @example
92
147
  * // 3. Diagonal Concatenation (mismatched columns):
93
- * >>> const df1 = $df.data({ a: [1] })
94
- * >>> const df2 = $df.data({ b: [2] })
148
+ * >>> const df1 = $df.data({ a: [1, 2] })
149
+ * >>> const df2 = $df.data({ b: [10, 20] })
150
+ * >>> df1
151
+ * shape: (2, 1)
152
+ * ┌───┐
153
+ * │ a │
154
+ * ├───┤
155
+ * │ 1 │
156
+ * │ 2 │
157
+ * └───┘
158
+ * >>> df2
159
+ * shape: (2, 1)
160
+ * ┌────┐
161
+ * │ b │
162
+ * ├────┤
163
+ * │ 10 │
164
+ * │ 20 │
165
+ * └────┘
95
166
  * >>> df1.concat(df2, { how: "diagonal" })
96
- * shape: (2, 2)
167
+ * shape: (4, 2)
97
168
  * ┌──────┬──────┐
98
169
  * │ a │ b │
99
170
  * ├──────┼──────┤
100
171
  * │ 1 │ null │
101
- * │ null │ 2 │
172
+ * │ 2 │ null │
173
+ * │ null │ 10 │
174
+ * │ null │ 20 │
102
175
  * └──────┴──────┘
103
- *
104
176
  */
105
177
  concat<U extends RowRecord = any>(items: ConcatItem | ConcatItem[], options?: ConcatOptions): DataFrame<U>;
106
178
  /**
@@ -108,39 +180,41 @@ export declare class DataFrame<T extends RowRecord = any> {
108
180
  * @param {(K | K[])[]} args Column names or arrays of column names to remove.
109
181
  * @returns {DataFrame}
110
182
  * @example
111
- * >>> const df = $df.data({ a: [1], b: [2] })
112
- * >>> df
113
- * shape: (1, 2)
114
- * ┌───┬───┐
115
- * │ a │ b │
116
- * ├───┼───┤
117
- * │ 1 │ 2
118
- * └───┴───┘
183
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
184
+ * >>> df
185
+ * shape: (2, 2)
186
+ * ┌───┬───┐
187
+ * │ a │ b │
188
+ * ├───┼───┤
189
+ * │ 1 │ x
190
+ * │ 2 │ y │
191
+ * └───┴───┘
119
192
  * >>> df.drop("b")
120
- * shape: (1, 1)
193
+ * shape: (2, 1)
121
194
  * ┌───┐
122
195
  * │ a │
123
196
  * ├───┤
124
197
  * │ 1 │
198
+ * │ 2 │
125
199
  * └───┘
126
200
  */
127
201
  drop<K extends keyof T>(...args: (K | K[])[]): DataFrame<Omit<T, K>>;
128
202
  /**
129
- * Drops rows containing null or undefined values in specified subset columns.
203
+ * Drops rows with null or undefined values.
130
204
  * @param {string | string[]} [subset] Column name or array of column names to check for nulls.
131
205
  * @returns {DataFrame}
132
206
  * @example
133
- * >>> const df = $df.data({ a: [1, null, 3] })
134
- * >>> df
135
- * shape: (3, 1)
136
- * ┌──────┐
137
- * │ a │
138
- * ├──────┤
139
- * │ 1 │
140
- * │ null │
141
- * │ 3 │
142
- * └──────┘
143
- * >>> df.drop_nulls()
207
+ * >>> const df = $df.data({ a: [1, null, 3], b: [null, 2, null] })
208
+ * >>> df
209
+ * shape: (3, 2)
210
+ * ┌──────┬──────┐
211
+ * │ a │ b │
212
+ * ├──────┼──────┤
213
+ * │ 1 │ null │
214
+ * │ null │ 2 │
215
+ * │ 3 │ null │
216
+ * └──────┴──────┘
217
+ * >>> df.dropNulls()
144
218
  * shape: (2, 1)
145
219
  * ┌───┐
146
220
  * │ a │
@@ -149,19 +223,20 @@ export declare class DataFrame<T extends RowRecord = any> {
149
223
  * │ 3 │
150
224
  * └───┘
151
225
  */
152
- drop_nulls(subset?: string | string[]): DataFrame<T>;
226
+ dropNulls(subset?: string | string[]): DataFrame<T>;
153
227
  /**
154
228
  * Gets array of registered column DataTypes matching current schema order.
155
229
  * @returns Array of RegisteredDataType definitions.
156
230
  * @example
157
- * >>> const df = $df.data({ a: [1], b: ["text"] })
158
- * >>> df
159
- * shape: (1, 2)
160
- * ┌───┬──────┐
161
- * │ a │ b
162
- * ├───┼──────┤
163
- * │ 1 │ text
164
- * └───┴──────┘
231
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
232
+ * >>> df
233
+ * shape: (2, 2)
234
+ * ┌───┬───┐
235
+ * │ a │ b
236
+ * ├───┼───┤
237
+ * │ 1 │ x
238
+ * │ 2 │ y │
239
+ * └───┴───┘
165
240
  * >>> df.dtypes
166
241
  * [Float64, Utf8]
167
242
  */
@@ -170,18 +245,19 @@ export declare class DataFrame<T extends RowRecord = any> {
170
245
  * Explodes an array column into multiple rows, replicating non-target row attributes.
171
246
  * @param {IntoExpr | IntoExpr[]} columns Target column expression or array column name to explode.
172
247
  * @param {ExplodeOptions} [options] Configuration options for empty array and null handling.
173
- * @param {boolean} [options.empty_as_null] When `true`, converts empty arrays to `null` rows.
174
- * @param {boolean} [options.keep_nulls] When `true`, retains `null` array values during explosion.
248
+ * @param {boolean} [options.emptyAsNull] When `true`, converts empty arrays to `null` rows.
249
+ * @param {boolean} [options.keepNulls] When `true`, retains `null` array values during explosion.
175
250
  * @returns {DataFrame}
176
251
  * @example
177
- * >>> const df = $df.data({ group: ["A"], values: [[1, 2]] })
178
- * >>> df
179
- * shape: (1, 2)
180
- * ┌───────┬────────┐
181
- * │ group values │
182
- * ├───────┼────────┤
183
- * │ A │ [1, 2] │
184
- * └───────┴────────┘
252
+ * >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
253
+ * >>> df
254
+ * shape: (2, 1)
255
+ * ┌───────────┐
256
+ * │ a
257
+ * ├───────────┤
258
+ * │ [1, 2, 3] │
259
+ * │ [4, 5] │
260
+ * └───────────┘
185
261
  * >>> df.explode("values")
186
262
  * shape: (2, 2)
187
263
  * ┌───────┬────────┐
@@ -200,17 +276,17 @@ export declare class DataFrame<T extends RowRecord = any> {
200
276
  * @param {number} [options.limit] Maximum consecutive nulls to fill when using propagation strategies.
201
277
  * @returns {DataFrame}
202
278
  * @example
203
- * >>> const df = $df.data({ a: [1, null, 3] })
204
- * >>> df
205
- * shape: (3, 1)
206
- * ┌──────┐
207
- * │ a │
208
- * ├──────┤
209
- * │ 1 │
210
- * │ null │
211
- * │ 3 │
212
- * └──────┘
213
- * >>> df.fill_null({ value: 0 })
279
+ * >>> const df = $df.data({ a: [1, null, 3], b: [null, 2, null] })
280
+ * >>> df
281
+ * shape: (3, 2)
282
+ * ┌──────┬──────┐
283
+ * │ a │ b │
284
+ * ├──────┼──────┤
285
+ * │ 1 │ null │
286
+ * │ null │ 2 │
287
+ * │ 3 │ null │
288
+ * └──────┴──────┘
289
+ * >>> df.fillNull({ value: 0 })
214
290
  * shape: (3, 1)
215
291
  * ┌───┐
216
292
  * │ a │
@@ -220,22 +296,22 @@ export declare class DataFrame<T extends RowRecord = any> {
220
296
  * │ 3 │
221
297
  * └───┘
222
298
  */
223
- fill_null(options?: FillNullOptions): DataFrame<T>;
299
+ fillNull(options?: FillNullOptions): DataFrame<T>;
224
300
  /**
225
301
  * Filters rows matching boolean column expressions or predicate callbacks.
226
302
  * @param {(IExpr | ((row: T) => any))[]} exprs Expressions or predicate functions evaluated per row.
227
303
  * @returns {DataFrame}
228
304
  * @example
229
- * >>> const df = $df.data({ a: [1, 2, 3] })
230
- * >>> df
231
- * shape: (3, 1)
232
- * ┌───┐
233
- * │ a │
234
- * ├───┤
235
- * │ 1 │
236
- * │ 2 │
237
- * │ 3 │
238
- * └───┘
305
+ * >>> const df = $df.data({ a: [1, 2, 3], b: [10, 20, 30] })
306
+ * >>> df
307
+ * shape: (3, 2)
308
+ * ┌───┬────┐
309
+ * │ a │ b │
310
+ * ├───┼────┤
311
+ * │ 1 │ 10 │
312
+ * │ 2 │ 20 │
313
+ * │ 3 │ 30 │
314
+ * └───┴────┘
239
315
  * >>> df.filter($df.col("a").gt(1))
240
316
  * shape: (2, 1)
241
317
  * ┌───┐
@@ -246,38 +322,22 @@ export declare class DataFrame<T extends RowRecord = any> {
246
322
  * └───┘
247
323
  */
248
324
  filter(...exprs: (IExpr | ((row: T) => any))[]): DataFrame<T>;
249
- /**
250
- * Returns the mapping dictionary of column names to DataType.
251
- * @returns DataFrameSchema
252
- * @example
253
- * >>> const df = $df.data({ a: [1], b: ["text"] })
254
- * >>> df
255
- * shape: (1, 2)
256
- * ┌───┬──────┐
257
- * │ a │ b │
258
- * ├───┼──────┤
259
- * │ 1 │ text │
260
- * └───┴──────┘
261
- * >>> df.get_schema()
262
- * { a: Float64, b: Utf8 }
263
- */
264
- get_schema(): DataFrameSchema;
265
325
  /**
266
326
  * Groups rows by key columns to prepare for aggregations.
267
327
  * @param {K | K[]} keys Column name or array of key column names.
268
328
  * @returns {GroupedData}
269
329
  * @example
270
- * >>> const df = $df.data({ cat: ["A", "A", "B"], val: [10, 20, 30] })
271
- * >>> df
272
- * shape: (3, 2)
273
- * ┌─────┬─────┐
274
- * │ cat │ val │
275
- * ├─────┼─────┤
276
- * │ A │ 10 │
277
- * │ A │ 20 │
278
- * │ B │ 30 │
279
- * └─────┴─────┘
280
- * >>> df.groupby("cat").agg($df.col("val").sum().alias("sum"))
330
+ * >>> const df = $df.data({ group: ["A", "A", "B"], val: [10, 20, 30] })
331
+ * >>> df
332
+ * shape: (3, 2)
333
+ * ┌───────┬─────┐
334
+ * │ group │ val │
335
+ * ├───────┼─────┤
336
+ * │ A │ 10 │
337
+ * │ A │ 20 │
338
+ * │ B │ 30 │
339
+ * └───────┴─────┘
340
+ * >>> df.groupBy("group").agg($df.col("val").sum().alias("sum"))
281
341
  * shape: (2, 2)
282
342
  * ┌─────┬─────┐
283
343
  * │ cat │ sum │
@@ -286,23 +346,53 @@ export declare class DataFrame<T extends RowRecord = any> {
286
346
  * │ B │ 30 │
287
347
  * └─────┴─────┘
288
348
  */
289
- groupby<K extends keyof T>(keys: K | K[]): GroupedData<T, K>;
349
+ groupBy<K extends keyof T>(keys: K | K[]): GroupedData<T, K>;
350
+ /**
351
+ * Groups dynamically based on a time or integer index column over sliding / stepping windows.
352
+ *
353
+ * @param indexColumn The time/integer column or column expression to group on.
354
+ * @param options Dynamic grouping configuration options (`every`, `period`, `offset`, `truncate`, `includeBoundaries`, `closed`, `label`, `by`, `startBy`, `checkSorted`).
355
+ * @returns GroupedData
356
+ * @example
357
+ * >>> const df = $df.data([
358
+ * ... { time: new Date("2024-01-01T00:00:00Z"), val: 10 },
359
+ * ... { time: new Date("2024-01-01T12:00:00Z"), val: 20 },
360
+ * ... { time: new Date("2024-01-02T00:00:00Z"), val: 30 }
361
+ * ... ])
362
+ * >>> df
363
+ * shape: (3, 2)
364
+ * ┌──────────────────────────┬─────┐
365
+ * │ time │ val │
366
+ * ├──────────────────────────┼─────┤
367
+ * │ 2024-01-01T00:00:00.000Z │ 10 │
368
+ * │ 2024-01-01T12:00:00.000Z │ 20 │
369
+ * │ 2024-01-02T00:00:00.000Z │ 30 │
370
+ * └──────────────────────────┴─────┘
371
+ * >>> df.groupByDynamic("time", { every: "1d", period: "1d" }).agg($df.col("val").sum().alias("daily_sum"))
372
+ * shape: (2, 2)
373
+ * ┌──────────────────────────┬───────────┐
374
+ * │ time │ daily_sum │
375
+ * ├──────────────────────────┼───────────┤
376
+ * │ 2024-01-01T00:00:00.000Z │ 30 │
377
+ * │ 2024-01-02T00:00:00.000Z │ 30 │
378
+ * └──────────────────────────┴───────────┘
379
+ */
380
+ groupByDynamic<K extends keyof T & string>(indexColumn: K | IntoExpr, options: GroupByDynamicOptions<T>): GroupedData<T, K>;
290
381
  /**
291
382
  * Returns the first N rows as a new DataFrame.
292
383
  * @param n Number of leading rows to slice (default 10).
293
384
  * @returns DataFrame
294
385
  * @example
295
- * >>> const df = $df.data({ a: [1, 2, 3, 4] })
296
- * >>> df
297
- * shape: (4, 1)
298
- * ┌───┐
299
- * │ a │
300
- * ├───┤
301
- * │ 1 │
302
- * │ 2 │
303
- * │ 3 │
304
- * │ 4 │
305
- * └───┘
386
+ * >>> const df = $df.data({ a: [1, 2, 3] })
387
+ * >>> df
388
+ * shape: (3, 1)
389
+ * ┌───┐
390
+ * │ a │
391
+ * ├───┤
392
+ * │ 1 │
393
+ * │ 2 │
394
+ * │ 3 │
395
+ * └───┘
306
396
  * >>> df.head(2)
307
397
  * shape: (2, 1)
308
398
  * ┌───┐
@@ -313,49 +403,19 @@ export declare class DataFrame<T extends RowRecord = any> {
313
403
  * └───┘
314
404
  */
315
405
  head(n?: number): DataFrame<T>;
316
- /**
317
- * Creates a deep copy of the current DataFrame instance, duplicating all underlying column data arrays and schema metadata.
318
- * Modifying columns or values in the cloned DataFrame will not mutate the original.
319
- * @returns {DataFrame<T>}
320
- * @example
321
- * >>> // Example 1: Basic cloning and independence
322
- * >>> const df1 = $df.data({ a: [10, 20], b: ["x", "y"] })
323
- * >>> const copy1 = df1.clone()
324
- * >>> copy1
325
- * shape: (2, 2)
326
- * ┌────┬───┐
327
- * │ a │ b │
328
- * ├────┼───┤
329
- * │ 10 │ x │
330
- * │ 20 │ y │
331
- * └────┴───┘
332
- *
333
- * >>> // Example 2: Verifying mutation isolation
334
- * >>> copy1._columns.a[0] = 999
335
- * >>> df1.to_dicts()[0].a
336
- * 10
337
- *
338
- * >>> // Example 3: Cloning empty DataFrames
339
- * >>> const emptyDf = $df.data({ x: [], y: [] })
340
- * >>> const emptyCopy = emptyDf.clone()
341
- * >>> emptyCopy.height
342
- * 0
343
- */
344
- clone(): DataFrame<T>;
345
406
  /**
346
407
  * Gets height (total row count) of the DataFrame.
347
408
  * @returns Number of rows.
348
409
  * @example
349
- * >>> const df = $df.data({ a: [10, 20, 30] })
350
- * >>> df
351
- * shape: (3, 1)
352
- * ┌────┐
353
- * │ a
354
- * ├────┤
355
- * │ 10
356
- * │ 20
357
- * │ 30 │
358
- * └────┘
410
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
411
+ * >>> df
412
+ * shape: (2, 2)
413
+ * ┌───┬───┐
414
+ * │ a b │
415
+ * ├───┼───┤
416
+ * │ 1 x │
417
+ * │ 2 y │
418
+ * └───┴───┘
359
419
  * >>> df.height
360
420
  * 3
361
421
  */
@@ -367,16 +427,24 @@ export declare class DataFrame<T extends RowRecord = any> {
367
427
  * @param {boolean} [options.strict] When `true` (default), throws an error if row counts mismatch. Set `false` to allow null padding.
368
428
  * @returns {DataFrame}
369
429
  * @example
370
- * >>> const df1 = $df.data({ a: [1, 2] })
371
- * >>> df1
372
- * shape: (2, 1)
373
- * ┌───┐
374
- * │ a │
375
- * ├───┤
376
- * │ 1 │
377
- * │ 2
378
- * └───┘
379
- * >>> const df2 = $df.data({ b: [10, 20] })
430
+ * >>> const df1 = $df.data({ a: [1, 2] })
431
+ * >>> const df2 = $df.data({ b: [10, 20] })
432
+ * >>> df1
433
+ * shape: (2, 1)
434
+ * ┌───┐
435
+ * │ a │
436
+ * ├───┤
437
+ * │ 1
438
+ * │ 2 │
439
+ * └───┘
440
+ * >>> df2
441
+ * shape: (2, 1)
442
+ * ┌────┐
443
+ * │ b │
444
+ * ├────┤
445
+ * │ 10 │
446
+ * │ 20 │
447
+ * └────┘
380
448
  * >>> df1.hstack(df2)
381
449
  * shape: (2, 2)
382
450
  * ┌───┬────┐
@@ -394,23 +462,25 @@ export declare class DataFrame<T extends RowRecord = any> {
394
462
  * @param {IntoExpr} expr Value expression or column definition.
395
463
  * @returns {DataFrame}
396
464
  * @example
397
- * >>> const df = $df.data({ a: [1], c: [3] })
398
- * >>> df
399
- * shape: (1, 2)
400
- * ┌───┬───┐
401
- * │ a │ c
402
- * ├───┼───┤
403
- * │ 1 │ 3
404
- * └───┴───┘
405
- * >>> df.insert_column(1, "b", 2)
406
- * shape: (1, 3)
407
- * ┌───┬───┬───┐
408
- * │ a │ b │ c │
409
- * ├───┼───┼───┤
410
- * │ 1 │ 2 │ 3 │
411
- * └───┴───┴───┘
465
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
466
+ * >>> df
467
+ * shape: (2, 2)
468
+ * ┌───┬───┐
469
+ * │ a │ b
470
+ * ├───┼───┤
471
+ * │ 1 │ x
472
+ * │ 2 │ y │
473
+ * └───┴───┘
474
+ * >>> df.insertColumn(1, "c", [10, 20])
475
+ * shape: (2, 3)
476
+ * ┌───┬────┬───┐
477
+ * │ a │ c │ b │
478
+ * ├───┼────┼───┤
479
+ * │ 1 │ 10 │ x │
480
+ * │ 2 │ 20 │ y │
481
+ * └───┴────┴───┘
412
482
  */
413
- insert_column(index: number, name: string, expr: IntoExpr): DataFrame<any>;
483
+ insertColumn(index: number, name: string, expr: IntoExpr): DataFrame<any>;
414
484
  /**
415
485
  * Retrieves a single scalar cell value by row and column position or name.
416
486
  * @param {number} [row] Row index position.
@@ -419,14 +489,15 @@ export declare class DataFrame<T extends RowRecord = any> {
419
489
  * @throws {DataFrameError} If shape is not (1, 1) when called without arguments.
420
490
  * @throws {ShapeError} If row or column index is out of bounds.
421
491
  * @example
422
- * >>> const df = $df.data({ val: [42] })
423
- * >>> df
424
- * shape: (1, 1)
425
- * ┌─────┐
426
- * │ val
427
- * ├─────┤
428
- * │ 42
429
- * └─────┘
492
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
493
+ * >>> df
494
+ * shape: (2, 2)
495
+ * ┌───┬───┐
496
+ * │ a b │
497
+ * ├───┼───┤
498
+ * │ 1 x │
499
+ * │ 2 │ y │
500
+ * └───┴───┘
430
501
  * >>> df.item(0, "val")
431
502
  * 42
432
503
  */
@@ -435,50 +506,48 @@ export declare class DataFrame<T extends RowRecord = any> {
435
506
  * Yields a generator iterating over raw column arrays.
436
507
  * @returns Generator of ColumnData arrays.
437
508
  * @example
438
- * >>> const df = $df.data({ a: [1, 2], b: [3, 4] })
439
- * >>> df
440
- * shape: (2, 2)
441
- * ┌───┬───┐
442
- * │ a │ b │
443
- * ├───┼───┤
444
- * │ 1 │ 3
445
- * │ 2 │ 4
446
- * └───┴───┘
447
- * >>> for (const col of df.iter_columns()) { console.log(col); }
448
- * Float64Array([1, 2])
449
- * Float64Array([3, 4])
509
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
510
+ * >>> df
511
+ * shape: (2, 2)
512
+ * ┌───┬───┐
513
+ * │ a │ b │
514
+ * ├───┼───┤
515
+ * │ 1 │ x
516
+ * │ 2 │ y
517
+ * └───┴───┘
518
+ * >>> Array.from(df.iterColumns())
519
+ * [ Float64Array([1, 2]), ["x", "y"] ]
450
520
  */
451
- iter_columns(): Generator<ColumnData>;
521
+ iterColumns(): Generator<ColumnData>;
452
522
  /**
453
523
  * Yields a generator iterating over rows as tuples or named objects.
454
524
  * @param [config] Iteration format configuration.
455
525
  * @param [config.named] When `true`, yields row objects with column keys (`{ col: val }`). When `false` (default), yields positional arrays (`[val1, val2]`).
456
526
  * @returns Generator of rows.
457
527
  * @example
458
- * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
459
- * >>> df
460
- * shape: (2, 2)
461
- * ┌───┬───┐
462
- * │ a │ b │
463
- * ├───┼───┤
464
- * │ 1 │ x │
465
- * │ 2 │ y │
466
- * └───┴───┘
467
- * >>> for (const row of df.iter_rows({ named: true })) { console.log(row); }
468
- * { a: 1, b: "x" }
469
- * { a: 2, b: "y" }
528
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
529
+ * >>> df
530
+ * shape: (2, 2)
531
+ * ┌───┬───┐
532
+ * │ a │ b │
533
+ * ├───┼───┤
534
+ * │ 1 │ x │
535
+ * │ 2 │ y │
536
+ * └───┴───┘
537
+ * >>> Array.from(df.iterRows({ named: true }))
538
+ * [ { a: 1, b: "x" }, { a: 2, b: "y" } ]
470
539
  */
471
- iter_rows({ named }?: {
540
+ iterRows({ named }?: {
472
541
  named?: boolean;
473
542
  }): Generator<any[] | Record<string, any>>;
474
543
  /**
475
544
  * Joins two DataFrames on key columns using a specified join strategy.
476
- * @param {JoinOptions} config Join configuration object.
477
- * @param {DataFrame} config.other Right DataFrame to join with.
478
- * @param {string | string[]} [config.on] Join key column name or array of key column names that exist in both DataFrames.
479
- * @param {string | string[]} [config.leftOn] Join key column(s) in the left DataFrame when key names differ.
480
- * @param {string | string[]} [config.rightOn] Join key column(s) in the right DataFrame when key names differ.
481
- * @param {JoinType} [config.how] Join strategy. Default `"inner"`.
545
+ * @param {DataFrame} other Right DataFrame to join with.
546
+ * @param {JoinOptions} [options={}] Join configuration object.
547
+ * @param {string | string[]} [options.on] Join key column name or array of key column names that exist in both DataFrames.
548
+ * @param {string | string[]} [options.leftOn] Join key column(s) in the left DataFrame when key names differ.
549
+ * @param {string | string[]} [options.rightOn] Join key column(s) in the right DataFrame when key names differ.
550
+ * @param {JoinType} [options.how] Join strategy. Default `"inner"`.
482
551
  * - `"inner"` — Only rows with matching keys in both DataFrames.
483
552
  * - `"left"` — All left rows; unmatched right values are `null`.
484
553
  * - `"right"` — All right rows; unmatched left values are `null`.
@@ -486,12 +555,12 @@ export declare class DataFrame<T extends RowRecord = any> {
486
555
  * - `"semi"` — Left rows that have a match in the right DataFrame (only left columns retained).
487
556
  * - `"anti"` — Left rows that have **no** match in the right DataFrame (only left columns retained).
488
557
  * - `"cross"` — Cartesian product pairing every left row with every right row (keyless).
489
- * @param {[string, string]} [config.suffixes] Suffix tuple `[leftSuffix, rightSuffix]` appended to overlapping
558
+ * @param {[string, string]} [options.suffixes] Suffix tuple `[leftSuffix, rightSuffix]` appended to overlapping
490
559
  * non-key column names (default `["", "_right"]`). Ignored for `"semi"` and `"anti"` joins.
491
- * @param {boolean} [config.join_nulls] If `true`, null key values are treated as equal and will match each other
560
+ * @param {boolean} [options.joinNulls] If `true`, null key values are treated as equal and will match each other
492
561
  * across DataFrames. Default `false` (SQL-standard: `NULL != NULL`).
493
- * @param {boolean} [config.coalesce] Coalescing behavior for join key columns. Default `true`. If `true`, coalesces join key values into left key columns and drops right key columns. If `false`, keeps join key columns separate.
494
- * @param {JoinMaintainOrder | boolean} [config.maintain_order] Row order preservation strategy. Default `"none"`.
562
+ * @param {boolean} [options.coalesce] Coalescing behavior for join key columns. Default `true`. If `true`, coalesces join key values into left key columns and drops right key columns. If `false`, keeps join key columns separate.
563
+ * @param {JoinMaintainOrder | boolean} [options.maintainOrder] Row order preservation strategy. Default `"none"`.
495
564
  * - `"none"` (or `false`) — No specific ordering is desired.
496
565
  * - `"left"` (or `true`) — Preserves the order of the left DataFrame.
497
566
  * - `"right"` — Preserves the order of the right DataFrame.
@@ -499,17 +568,25 @@ export declare class DataFrame<T extends RowRecord = any> {
499
568
  * - `"right_left"` — Preserves the order of the right DataFrame first, then the left.
500
569
  * @returns {DataFrame}
501
570
  * @example
502
- * >>> const df1 = $df.data({ id: [1, 2], val: ["a", "b"] })
503
- * >>> df1
504
- * shape: (2, 2)
505
- * ┌────┬─────┐
506
- * │ id │ val │
507
- * ├────┼─────┤
508
- * │ 1 │ a │
509
- * │ 2b
510
- * └────┴─────┘
511
- * >>> const df2 = $df.data({ id: [1, 2], num: [100, 200] })
512
- * >>> df1.join({ other: df2, on: "id" })
571
+ * >>> const df1 = $df.data({ id: [1, 2], val: ["a", "b"] })
572
+ * >>> const df2 = $df.data({ id: [1, 2], num: [100, 200] })
573
+ * >>> df1
574
+ * shape: (2, 2)
575
+ * ┌────┬─────┐
576
+ * │ id │ val │
577
+ * ├────┼─────┤
578
+ * │ 1a
579
+ * │ 2 │ b │
580
+ * └────┴─────┘
581
+ * >>> df2
582
+ * shape: (2, 2)
583
+ * ┌────┬─────┐
584
+ * │ id │ num │
585
+ * ├────┼─────┤
586
+ * │ 1 │ 100 │
587
+ * │ 2 │ 200 │
588
+ * └────┴─────┘
589
+ * >>> df1.join(df2, { on: "id" })
513
590
  * shape: (2, 3)
514
591
  * ┌────┬─────┬─────┐
515
592
  * │ id │ val │ num │
@@ -518,7 +595,7 @@ export declare class DataFrame<T extends RowRecord = any> {
518
595
  * │ 2 │ b │ 200 │
519
596
  * └────┴─────┴─────┘
520
597
  */
521
- join<U extends RowRecord = any, R extends RowRecord = any>(config: JoinOptions<T, U>): DataFrame<R>;
598
+ join<U extends RowRecord = any, R extends RowRecord = any>(other: DataFrame<U>, options?: JoinOptions<T, U>): DataFrame<R>;
522
599
  /**
523
600
  * Performs an asof (as-of) join for inexact matching on ordered numeric or temporal key columns.
524
601
  *
@@ -526,71 +603,123 @@ export declare class DataFrame<T extends RowRecord = any> {
526
603
  * DataFrame according to the selected `strategy` ("backward", "forward", or "nearest") and optional `tolerance`.
527
604
  * Both DataFrames must be sorted in ascending order on their respective `on` / `leftOn` / `rightOn` join keys.
528
605
  *
529
- * @param {AsofJoinOptions} options Asof join configuration options.
530
- * @param {DataFrame} options.other The right DataFrame to join with.
606
+ * @param {DataFrame} other The right DataFrame to join with.
607
+ * @param {JoinAsofOptions} options Asof join configuration options.
531
608
  * @param {string} [options.on] Column name to join on (must exist in both DataFrames and be sorted ascending).
532
609
  * @param {string} [options.leftOn] Left DataFrame join key column name.
533
610
  * @param {string} [options.rightOn] Right DataFrame join key column name.
534
611
  * @param {string | string[]} [options.by] Optional exact-match group column(s) present in both DataFrames.
535
612
  * @param {string | string[]} [options.leftBy] Group column(s) for exact key matching in left DataFrame.
536
613
  * @param {string | string[]} [options.rightBy] Group column(s) for exact key matching in right DataFrame.
537
- * @param {AsofJoinStrategy} [options.strategy] Match search strategy. Default `"backward"`.
614
+ * @param {JoinAsofStrategy} [options.strategy] Match search strategy. Default `"backward"`.
538
615
  * - `"backward"` — Matches the latest right row where `rightKey <= leftKey`.
539
616
  * - `"forward"` — Matches the earliest right row where `rightKey >= leftKey`.
540
617
  * - `"nearest"` — Matches the right row with the absolute nearest key value to `leftKey`.
541
618
  * @param {number | string} [options.tolerance] Maximum allowed distance between left key and right key.
542
- * @param {boolean} [options.allow_exact_matches] Whether exact key matches are permitted. Default `true`.
619
+ * @param {boolean} [options.allowExactMatches] Whether exact key matches are permitted. Default `true`.
543
620
  * @param {[string, string]} [options.suffixes] Column name suffixes `[leftSuffix, rightSuffix]` to resolve name collisions. Default `["", "_right"]`.
544
621
  * @param {boolean} [options.coalesce] Coalescing behavior for join key columns. Default `true`.
545
- * @param {boolean} [options.check_sorted] Whether to verify that join keys are sorted ascending prior to matching. Default `true`.
622
+ * @param {boolean} [options.checkSorted] Whether to verify that join keys are sorted ascending prior to matching. Default `true`.
546
623
  * @returns A new DataFrame containing the joined results.
547
- *
548
- * @namespace df
549
- * @category DataFrame
550
- * @syntax
551
- * df.join_asof({
552
- * other,
553
- * on,
554
- * leftOn,
555
- * rightOn,
556
- * by,
557
- * leftBy,
558
- * rightBy,
559
- * strategy,
560
- * tolerance,
561
- * allow_exact_matches,
562
- * suffixes,
563
- * coalesce,
564
- * check_sorted
565
- * })
566
624
  * @example
567
- * >>> const trades = new DataFrame([
568
- * ... { time: 1000, ticker: "AAPL", price: 150.0 },
569
- * ... { time: 1005, ticker: "AAPL", price: 150.5 },
570
- * ... { time: 1015, ticker: "AAPL", price: 151.0 }
571
- * ... ]);
572
- * >>> const quotes = new DataFrame([
573
- * ... { time: 998, ticker: "AAPL", bid: 149.9 },
574
- * ... { time: 1004, ticker: "AAPL", bid: 150.4 },
575
- * ... { time: 1010, ticker: "AAPL", bid: 150.8 }
576
- * ... ]);
577
- * >>> const joined = trades.join_asof({
578
- * ... other: quotes,
579
- * ... on: "time",
580
- * ... by: "ticker",
581
- * ... strategy: "backward"
582
- * ... });
583
- * >>> joined
625
+ * >>> const trades = $df.data([
626
+ * ... { time: 1000, ticker: "AAPL", price: 150.0 },
627
+ * ... { time: 1005, ticker: "AAPL", price: 150.5 },
628
+ * ... { time: 1015, ticker: "AAPL", price: 151.0 }
629
+ * ... ])
630
+ * >>> const quotes = $df.data([
631
+ * ... { time: 998, ticker: "AAPL", bid: 149.9 },
632
+ * ... { time: 1004, ticker: "AAPL", bid: 150.4 },
633
+ * ... { time: 1010, ticker: "AAPL", bid: 150.8 }
634
+ * ... ])
635
+ * >>> trades
636
+ * shape: (3, 3)
637
+ * ┌──────┬────────┬───────┐
638
+ * time │ ticker │ price │
639
+ * ├──────┼────────┼───────┤
640
+ * 1000 │ AAPL │ 150.0 │
641
+ * 1005 │ AAPL │ 150.5 │
642
+ * │ 1015 │ AAPL │ 151.0 │
643
+ * └──────┴────────┴───────┘
644
+ * >>> quotes
645
+ * shape: (3, 3)
646
+ * ┌──────┬────────┬───────┐
647
+ * │ time │ ticker │ bid │
648
+ * ├──────┼────────┼───────┤
649
+ * │ 998 │ AAPL │ 149.9 │
650
+ * │ 1004 │ AAPL │ 150.4 │
651
+ * │ 1010 │ AAPL │ 150.8 │
652
+ * └──────┴────────┴───────┘
653
+ * >>> trades.joinAsof(quotes, { on: "time", by: "ticker" })
584
654
  * shape: (3, 4)
585
- * ┌──────┬────────┬───────┬──────┐
586
- * │ time │ ticker │ price │ bid
587
- * ├──────┼────────┼───────┼──────┤
588
- * │ 1000 │ AAPL │ 150.0 │ 149.9│
589
- * │ 1005 │ AAPL │ 150.5 │ 150.4│
590
- * │ 1015 │ AAPL │ 151.0 │ 150.8│
591
- * └──────┴────────┴───────┴──────┘
655
+ * ┌──────┬────────┬───────┬───────┐
656
+ * │ time │ ticker │ price │ bid
657
+ * ├──────┼────────┼───────┼───────┤
658
+ * │ 1000 │ AAPL │ 150.0 │ 149.9
659
+ * │ 1005 │ AAPL │ 150.5 │ 150.4
660
+ * │ 1015 │ AAPL │ 151.0 │ 150.8
661
+ * └──────┴────────┴───────┴───────┘
662
+ */
663
+ joinAsof<U extends RowRecord = any, R extends RowRecord = any>(other: DataFrame<U>, options: JoinAsofOptions<T, U>): DataFrame<R>;
664
+ /**
665
+ * Joins two DataFrames based on arbitrary expression predicates (non-equi joins).
666
+ *
667
+ * Evaluates one or more boolean expressions across combined rows from both DataFrames.
668
+ * When column names collide between the two DataFrames, columns are suffixed according to
669
+ * `options.suffixes` (default `["", "_right"]`).
670
+ *
671
+ * @param {DataFrame} other The right DataFrame to join with.
672
+ * @param {...(IntoExpr | IntoExpr[] | JoinWhereOptions)} args Predicate expression(s), arrays of expressions,
673
+ * and an optional configuration options object (`{ how, suffixes }`).
674
+ * @returns {DataFrame} A new DataFrame containing the joined results.
675
+ * @example
676
+ * >>> const east = $df.data([
677
+ * ... { id: 100, dur: 120, rev: 12, cores: 2 },
678
+ * ... { id: 101, dur: 140, rev: 14, cores: 8 },
679
+ * ... { id: 102, dur: 160, rev: 16, cores: 4 }
680
+ * ... ])
681
+ * >>> const west = $df.data([
682
+ * ... { t_id: 404, time: 90, cost: 9, cores: 4 },
683
+ * ... { t_id: 498, time: 130, cost: 13, cores: 2 },
684
+ * ... { t_id: 676, time: 150, cost: 15, cores: 1 },
685
+ * ... { t_id: 742, time: 170, cost: 16, cores: 4 }
686
+ * ... ])
687
+ * >>> east
688
+ * shape: (3, 4)
689
+ * ┌─────┬─────┬─────┬───────┐
690
+ * │ id │ dur │ rev │ cores │
691
+ * ├─────┼─────┼─────┼───────┤
692
+ * │ 100 │ 120 │ 12 │ 2 │
693
+ * │ 101 │ 140 │ 14 │ 8 │
694
+ * │ 102 │ 160 │ 16 │ 4 │
695
+ * └─────┴─────┴─────┴───────┘
696
+ * >>> west
697
+ * shape: (4, 4)
698
+ * ┌──────┬──────┬──────┬───────┐
699
+ * │ t_id │ time │ cost │ cores │
700
+ * ├──────┼──────┼──────┼───────┤
701
+ * │ 404 │ 90 │ 9 │ 4 │
702
+ * │ 498 │ 130 │ 13 │ 2 │
703
+ * │ 676 │ 150 │ 15 │ 1 │
704
+ * │ 742 │ 170 │ 16 │ 4 │
705
+ * └──────┴──────┴──────┴───────┘
706
+ * >>> east.joinWhere(
707
+ * ... west,
708
+ * ... $df.col("dur").lt($df.col("time")),
709
+ * ... $df.col("rev").lt($df.col("cost"))
710
+ * ... )
711
+ * shape: (5, 8)
712
+ * ┌─────┬─────┬─────┬───────┬──────┬──────┬──────┬─────────────┐
713
+ * │ id │ dur │ rev │ cores │ t_id │ time │ cost │ cores_right │
714
+ * ├─────┼─────┼─────┼───────┼──────┼──────┼──────┼─────────────┤
715
+ * │ 100 │ 120 │ 12 │ 2 │ 498 │ 130 │ 13 │ 2 │
716
+ * │ 100 │ 120 │ 12 │ 2 │ 676 │ 150 │ 15 │ 1 │
717
+ * │ 100 │ 120 │ 12 │ 2 │ 742 │ 170 │ 16 │ 4 │
718
+ * │ 101 │ 140 │ 14 │ 8 │ 676 │ 150 │ 15 │ 1 │
719
+ * │ 101 │ 140 │ 14 │ 8 │ 742 │ 170 │ 16 │ 4 │
720
+ * └─────┴─────┴─────┴───────┴──────┴──────┴──────┴─────────────┘
592
721
  */
593
- join_asof<U extends RowRecord = any, R extends RowRecord = any>(options: AsofJoinOptions<T, U>): DataFrame<R>;
722
+ joinWhere<U extends RowRecord = any, R extends RowRecord = any>(other: DataFrame<U>, ...args: (IntoExpr | IntoExpr[] | JoinWhereOptions)[]): DataFrame<R>;
594
723
  /**
595
724
  * Limits the output to N rows starting from offset.
596
725
  * @param {number} n Maximum number of rows to take.
@@ -599,17 +728,16 @@ export declare class DataFrame<T extends RowRecord = any> {
599
728
  * @param {LimitPosition} [options.from] Slice direction starting point (`"start"` or `"end"`). Default `"start"`.
600
729
  * @returns {DataFrame}
601
730
  * @example
602
- * >>> const df = $df.data({ a: [10, 20, 30, 40] })
603
- * >>> df
604
- * shape: (4, 1)
605
- * ┌────┐
606
- * │ a
607
- * ├────┤
608
- * │ 10
609
- * │ 20
610
- * │ 30
611
- * │ 40 │
612
- * └────┘
731
+ * >>> const df = $df.data({ a: [1, 2, 3] })
732
+ * >>> df
733
+ * shape: (3, 1)
734
+ * ┌───┐
735
+ * │ a
736
+ * ├───┤
737
+ * │ 1
738
+ * │ 2
739
+ * │ 3
740
+ * └───┘
613
741
  * >>> df.limit(2, { offset: 1 })
614
742
  * shape: (2, 1)
615
743
  * ┌────┐
@@ -629,21 +757,17 @@ export declare class DataFrame<T extends RowRecord = any> {
629
757
  * @param {AggFn | string} [config.agg] Aggregation function to apply when multiple values exist for a cell.
630
758
  * @returns DataFrame
631
759
  * @example
632
- * >>> const df = $df.data({
633
- * ... year: [2020, 2020, 2021, 2021],
634
- * ... month: ["Jan", "Feb", "Jan", "Feb"],
635
- * ... revenue: [100, 150, 120, 180]
636
- * ... })
637
- * >>> df
638
- * shape: (4, 3)
639
- * ┌──────┬───────┬─────────┐
640
- * │ yearmonth revenue
641
- * ├──────┼───────┼─────────┤
642
- * │ 2020 │ Jan │ 100 │
643
- * │ 2020 │ Feb │ 150 │
644
- * │ 2021 │ Jan │ 120 │
645
- * │ 2021 │ Feb │ 180 │
646
- * └──────┴───────┴─────────┘
760
+ * >>> const df = $df.data({ year: [2020, 2020, 2021, 2021], month: ["Jan", "Feb", "Jan", "Feb"], revenue: [100, 150, 120, 180] })
761
+ * >>> df
762
+ * shape: (4, 3)
763
+ * ┌──────┬───────┬─────────┐
764
+ * year │ month │ revenue │
765
+ * ├──────┼───────┼─────────┤
766
+ * 2020 │ Jan │ 100 │
767
+ * │ 2020 │ Feb │ 150 │
768
+ * │ 2021Jan 120
769
+ * │ 2021 │ Feb │ 180 │
770
+ * └──────┴───────┴─────────┘
647
771
  * >>> df.pivot({ index: "year", columns: "month", values: "revenue" })
648
772
  * shape: (2, 3)
649
773
  * ┌──────┬─────┬─────┐
@@ -659,60 +783,61 @@ export declare class DataFrame<T extends RowRecord = any> {
659
783
  * @param {Partial<Record<keyof T, string>>} [mapping] Dictionary mapping old column names to new names.
660
784
  * @returns {DataFrame}
661
785
  * @example
662
- * >>> const df = $df.data({ old_name: [1] })
663
- * >>> df
664
- * shape: (1, 1)
665
- * ┌──────────┐
666
- * │ old_name
667
- * ├──────────┤
668
- * │ 1
669
- * └──────────┘
670
- * >>> df.rename({ old_name: "new_name" })
671
- * shape: (1, 1)
672
- * ┌──────────┐
673
- * │ new_name │
674
- * ├──────────┤
675
- * │ 1 │
676
- * └──────────┘
786
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
787
+ * >>> df
788
+ * shape: (2, 2)
789
+ * ┌───┬───┐
790
+ * │ a b │
791
+ * ├───┼───┤
792
+ * │ 1 x │
793
+ * │ 2 │ y │
794
+ * └───┴───┘
795
+ * >>> df.rename({ a: "id", b: "label" })
796
+ * shape: (2, 2)
797
+ * ┌────┬───────┐
798
+ * │ id │ label │
799
+ * ├────┼───────┤
800
+ * │ 1 │ x │
801
+ * │ 2 │ y │
802
+ * └────┴───────┘
677
803
  */
678
804
  rename(mapping?: Partial<Record<keyof T, string>>): DataFrame<any>;
679
805
  /**
680
806
  * Reverses the row ordering of the DataFrame.
681
807
  * @returns DataFrame
682
808
  * @example
683
- * >>> const df = $df.data({ a: [1, 2, 3] })
684
- * >>> df
685
- * shape: (3, 1)
686
- * ┌───┐
687
- * │ a │
688
- * ├───┤
689
- * │ 1 │
690
- * │ 2 │
691
- * │ 3 │
692
- * └───┘
809
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
810
+ * >>> df
811
+ * shape: (2, 2)
812
+ * ┌───┬───┐
813
+ * │ a │ b │
814
+ * ├───┼───┤
815
+ * │ 1 │ x │
816
+ * │ 2 │ y │
817
+ * └───┴───┘
693
818
  * >>> df.reverse()
694
- * shape: (3, 1)
695
- * ┌───┐
696
- * │ a │
697
- * ├───┤
698
- * │ 3
699
- * │ 2
700
- * │ 1 │
701
- * └───┘
819
+ * shape: (2, 2)
820
+ * ┌───┬───┐
821
+ * │ a │ b │
822
+ * ├───┼───┤
823
+ * │ 2 y │
824
+ * │ 1 x │
825
+ * └───┴───┘
702
826
  */
703
827
  reverse(): DataFrame<T>;
704
828
  /**
705
829
  * Gets current DataFrameSchema dictionary mapping column names to DataType.
706
830
  * @returns DataFrameSchema mapping.
707
831
  * @example
708
- * >>> const df = $df.data({ a: [1], b: ["text"] })
709
- * >>> df
710
- * shape: (1, 2)
711
- * ┌───┬──────┐
712
- * │ a │ b
713
- * ├───┼──────┤
714
- * │ 1 │ text
715
- * └───┴──────┘
832
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
833
+ * >>> df
834
+ * shape: (2, 2)
835
+ * ┌───┬───┐
836
+ * │ a │ b
837
+ * ├───┼───┤
838
+ * │ 1 │ x
839
+ * │ 2 │ y │
840
+ * └───┴───┘
716
841
  * >>> df.schema
717
842
  * { a: Float64, b: Utf8 }
718
843
  */
@@ -722,15 +847,15 @@ export declare class DataFrame<T extends RowRecord = any> {
722
847
  * @param {(string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]} args Column names, column expressions, or object maps to evaluate.
723
848
  * @returns {DataFrame}
724
849
  * @example
725
- * >>> const df = $df.data({ a: [1, 2], b: [10, 20] })
726
- * >>> df
727
- * shape: (2, 2)
728
- * ┌───┬────┐
729
- * │ a │ b
730
- * ├───┼────┤
731
- * │ 1 │ 10
732
- * │ 2 │ 20
733
- * └───┴────┘
850
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
851
+ * >>> df
852
+ * shape: (2, 2)
853
+ * ┌───┬───┐
854
+ * │ a │ b
855
+ * ├───┼───┤
856
+ * │ 1 │ x
857
+ * │ 2 │ y
858
+ * └───┴───┘
734
859
  * >>> df.select("a", $df.col("b").add(100).alias("b_plus"))
735
860
  * shape: (2, 2)
736
861
  * ┌───┬────────┐
@@ -745,15 +870,15 @@ export declare class DataFrame<T extends RowRecord = any> {
745
870
  * Gets DataFrame dimensions as [height, width] tuple.
746
871
  * @returns Tuple [height, width].
747
872
  * @example
748
- * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
749
- * >>> df
750
- * shape: (2, 2)
751
- * ┌───┬───┐
752
- * │ a │ b │
753
- * ├───┼───┤
754
- * │ 1 │ x │
755
- * │ 2 │ y │
756
- * └───┴───┘
873
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
874
+ * >>> df
875
+ * shape: (2, 2)
876
+ * ┌───┬───┐
877
+ * │ a │ b │
878
+ * ├───┼───┤
879
+ * │ 1 │ x │
880
+ * │ 2 │ y │
881
+ * └───┴───┘
757
882
  * >>> df.shape
758
883
  * [2, 2]
759
884
  */
@@ -764,17 +889,16 @@ export declare class DataFrame<T extends RowRecord = any> {
764
889
  * @param {number} [end] Optional ending row index (exclusive).
765
890
  * @returns {DataFrame}
766
891
  * @example
767
- * >>> const df = $df.data({ a: [10, 20, 30, 40] })
768
- * >>> df
769
- * shape: (4, 1)
770
- * ┌────┐
771
- * │ a
772
- * ├────┤
773
- * │ 10
774
- * │ 20
775
- * │ 30
776
- * │ 40 │
777
- * └────┘
892
+ * >>> const df = $df.data({ a: [1, 2, 3] })
893
+ * >>> df
894
+ * shape: (3, 1)
895
+ * ┌───┐
896
+ * │ a
897
+ * ├───┤
898
+ * │ 1
899
+ * │ 2
900
+ * │ 3
901
+ * └───┘
778
902
  * >>> df.slice(1, 3)
779
903
  * shape: (2, 1)
780
904
  * ┌────┐
@@ -794,25 +918,25 @@ export declare class DataFrame<T extends RowRecord = any> {
794
918
  * @param {Partial<Record<keyof T, (a: any, b: any) => number>>} [config.custom] Optional dictionary mapping column names to custom comparator functions.
795
919
  * @returns {DataFrame}
796
920
  * @example
797
- * >>> const df = $df.data({ val: [3, 1, 2] })
798
- * >>> df
799
- * shape: (3, 1)
800
- * ┌─────┐
801
- * │ val
802
- * ├─────┤
803
- * │ 3
804
- * │ 1
805
- * │ 2
806
- * └─────┘
807
- * >>> df.sort({ by: "val" })
808
- * shape: (3, 1)
809
- * ┌─────┐
810
- * │ val
811
- * ├─────┤
812
- * │ 1
813
- * │ 2
814
- * │ 3
815
- * └─────┘
921
+ * >>> const df = $df.data({ a: [1, 2, 3], b: [10, 20, 30] })
922
+ * >>> df
923
+ * shape: (3, 2)
924
+ * ┌───┬────┐
925
+ * │ a b │
926
+ * ├───┼────┤
927
+ * │ 1 10 │
928
+ * │ 2 20 │
929
+ * │ 3 30 │
930
+ * └───┴────┘
931
+ * >>> df.sort({ by: "a", descending: true })
932
+ * shape: (3, 2)
933
+ * ┌───┬────┐
934
+ * │ a b │
935
+ * ├───┼────┤
936
+ * │ 3 30 │
937
+ * │ 2 20 │
938
+ * │ 1 10 │
939
+ * └───┴────┘
816
940
  */
817
941
  sort(config?: SortOptions<T>): DataFrame<T>;
818
942
  /**
@@ -820,17 +944,16 @@ export declare class DataFrame<T extends RowRecord = any> {
820
944
  * @param n Number of trailing rows to take (default 10).
821
945
  * @returns DataFrame
822
946
  * @example
823
- * >>> const df = $df.data({ a: [1, 2, 3, 4] })
824
- * >>> df
825
- * shape: (4, 1)
826
- * ┌───┐
827
- * │ a │
828
- * ├───┤
829
- * │ 1 │
830
- * │ 2 │
831
- * │ 3 │
832
- * │ 4 │
833
- * └───┘
947
+ * >>> const df = $df.data({ a: [1, 2, 3] })
948
+ * >>> df
949
+ * shape: (3, 1)
950
+ * ┌───┐
951
+ * │ a │
952
+ * ├───┤
953
+ * │ 1 │
954
+ * │ 2 │
955
+ * │ 3 │
956
+ * └───┘
834
957
  * >>> df.tail(2)
835
958
  * shape: (2, 1)
836
959
  * ┌───┐
@@ -841,75 +964,78 @@ export declare class DataFrame<T extends RowRecord = any> {
841
964
  * └───┘
842
965
  */
843
966
  tail(n?: number): DataFrame<T>;
967
+ /**
968
+ * Evaluates a column expression or retrieves column values as a raw JavaScript array.
969
+ * @param {K | IExpr} nameOrExpr Target column name or column expression.
970
+ * @returns {any[]} Array of column scalar values.
971
+ * @example
972
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
973
+ * >>> df
974
+ * shape: (2, 2)
975
+ * ┌───┬───┐
976
+ * │ a │ b │
977
+ * ├───┼───┤
978
+ * │ 1 │ x │
979
+ * │ 2 │ y │
980
+ * └───┴───┘
981
+ * >>> df.toArray("a")
982
+ * [10, 20]
983
+ */
984
+ toArray<K extends keyof T>(nameOrExpr: K | IExpr): any[];
844
985
  /**
845
986
  * Converts columns into a JavaScript dictionary mapping column keys to raw arrays.
846
987
  * @returns Column dictionary map.
847
988
  * @example
848
- * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
849
- * >>> df
850
- * shape: (2, 2)
851
- * ┌───┬───┐
852
- * │ a │ b │
853
- * ├───┼───┤
854
- * │ 1 │ x │
855
- * │ 2 │ y │
856
- * └───┴───┘
857
- * >>> df.to_dict()
989
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
990
+ * >>> df
991
+ * shape: (2, 2)
992
+ * ┌───┬───┐
993
+ * │ a │ b │
994
+ * ├───┼───┤
995
+ * │ 1 │ x │
996
+ * │ 2 │ y │
997
+ * └───┴───┘
998
+ * >>> df.toDict()
858
999
  * { a: Float64Array([1, 2]), b: ["x", "y"] }
859
1000
  */
860
- to_dict(): DataFrameColumns<T>;
1001
+ toDict(): DataFrameColumns<T>;
861
1002
  /**
862
1003
  * Converts rows into an array of JavaScript objects.
863
1004
  * @returns Array of row record objects.
864
1005
  * @example
865
- * >>> const df = $df.data({ a: [1], b: ["x"] })
866
- * >>> df
867
- * shape: (1, 2)
868
- * ┌───┬───┐
869
- * │ a │ b │
870
- * ├───┼───┤
871
- * │ 1 │ x │
872
- * └───┴───┘
873
- * >>> df.to_dicts()
1006
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
1007
+ * >>> df
1008
+ * shape: (2, 2)
1009
+ * ┌───┬───┐
1010
+ * │ a │ b │
1011
+ * ├───┼───┤
1012
+ * │ 1 │ x │
1013
+ * │ 2 │ y │
1014
+ * └───┴───┘
1015
+ * >>> df.toDicts()
874
1016
  * [{ a: 1, b: "x" }]
875
1017
  */
876
- to_dicts(): T[];
877
- /**
878
- * Evaluates a column expression or retrieves column values as a raw JavaScript array.
879
- * @param {K | IExpr} nameOrExpr Target column name or column expression.
880
- * @returns {any[]} Array of column scalar values.
881
- * @example
882
- * >>> const df = $df.data({ a: [10, 20] })
883
- * >>> df
884
- * shape: (2, 1)
885
- * ┌────┐
886
- * │ a │
887
- * ├────┤
888
- * │ 10 │
889
- * │ 20 │
890
- * └────┘
891
- * >>> df.to_array("a")
892
- * [10, 20]
893
- */
894
- to_array<K extends keyof T>(nameOrExpr: K | IExpr): any[];
1018
+ toDicts(): T[];
895
1019
  /**
896
1020
  * Transposes rows into columns and columns into rows.
897
1021
  * @param {TransposeOptions} [options] Transpose layout options.
898
- * @param {boolean} [options.include_header] When `true`, includes original column names as a new header column (default `false`).
899
- * @param {string} [options.header_name] Name of the header column when `include_header` is `true` (default `"column"`).
900
- * @param {string | Iterable<string>} [options.column_names] Column name or iterable of strings to use as transposed column headers.
1022
+ * @param {boolean} [options.includeHeader] When `true`, includes original column names as a new header column (default `false`).
1023
+ * @param {string} [options.headerName] Name of the header column when `includeHeader` is `true` (default `"column"`).
1024
+ * @param {string | Iterable<string>} [options.columnNames] Column name or iterable of strings to use as transposed column headers.
901
1025
  * @returns {DataFrame}
902
1026
  * @example
903
- * >>> const df = $df.data({ metric: ["sales", "clicks"], q1: [100, 500], q2: [120, 600] })
904
- * >>> df
905
- * shape: (2, 3)
906
- * ┌────────┬─────┬─────┐
907
- * │ metricq1 q2
908
- * ├────────┼─────┼─────┤
909
- * │ sales 100 120
910
- * │ clicks500 600
911
- * └────────┴─────┴─────┘
912
- * >>> df.transpose({ include_header: true, header_name: "metric" })
1027
+ * >>> const df = $df.data({ year: [2020, 2020, 2021, 2021], month: ["Jan", "Feb", "Jan", "Feb"], revenue: [100, 150, 120, 180] })
1028
+ * >>> df
1029
+ * shape: (4, 3)
1030
+ * ┌──────┬───────┬─────────┐
1031
+ * │ yearmonth revenue
1032
+ * ├──────┼───────┼─────────┤
1033
+ * │ 2020 Jan 100
1034
+ * │ 2020Feb 150
1035
+ * │ 2021 │ Jan │ 120 │
1036
+ * 2021 Feb │ 180 │
1037
+ * └──────┴───────┴─────────┘
1038
+ * >>> df.transpose({ includeHeader: true, headerName: "metric" })
913
1039
  * shape: (2, 3)
914
1040
  * ┌────────┬──────────┬──────────┐
915
1041
  * │ metric │ column_0 │ column_1 │
@@ -918,22 +1044,21 @@ export declare class DataFrame<T extends RowRecord = any> {
918
1044
  * │ q2 │ 120 │ 600 │
919
1045
  * └────────┴──────────┴──────────┘
920
1046
  */
921
- transpose({ include_header: includeHeader, header_name: headerName, column_names: colNamesOpt }?: TransposeOptions): DataFrame<any>;
1047
+ transpose({ includeHeader: includeHeader, headerName: headerName, columnNames: colNamesOpt }?: TransposeOptions): DataFrame<any>;
922
1048
  /**
923
1049
  * Filters distinct unique rows matching target key columns.
924
1050
  * @param {K | K[]} [columns] Target column or array of column names to evaluate uniqueness.
925
1051
  * @returns {DataFrame}
926
1052
  * @example
927
- * >>> const df = $df.data({ a: [1, 2, 2], b: ["x", "y", "y"] })
928
- * >>> df
929
- * shape: (3, 2)
930
- * ┌───┬───┐
931
- * │ a │ b │
932
- * ├───┼───┤
933
- * │ 1 │ x │
934
- * │ 2 │ y │
935
- * │ 2 │ y │
936
- * └───┴───┘
1053
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
1054
+ * >>> df
1055
+ * shape: (2, 2)
1056
+ * ┌───┬───┐
1057
+ * │ a │ b │
1058
+ * ├───┼───┤
1059
+ * │ 1 │ x │
1060
+ * │ 2 │ y │
1061
+ * └───┴───┘
937
1062
  * >>> df.unique()
938
1063
  * shape: (2, 2)
939
1064
  * ┌───┬───┐
@@ -953,22 +1078,27 @@ export declare class DataFrame<T extends RowRecord = any> {
953
1078
  * @param {string} [config.valueName] Name for the new value column holding cell values (default `"value"`).
954
1079
  * @returns {DataFrame}
955
1080
  * @example
956
- * >>> const df = $df.data({ year: [2020], Jan: [100], Feb: [150] })
957
- * >>> df
958
- * shape: (1, 3)
959
- * ┌──────┬─────┬─────┐
960
- * │ year │ JanFeb
961
- * ├──────┼─────┼─────┤
962
- * │ 2020 │ 100 150
963
- * └──────┴─────┴─────┘
964
- * >>> df.unpivot({ idVars: "year", valueVars: ["Jan", "Feb"], varName: "month", valueName: "revenue" })
965
- * shape: (2, 3)
966
- * ┌──────┬───────┬─────────┐
967
- * year month revenue
968
- * ├──────┼───────┼─────────┤
969
- * │ 2020 │ Jan │ 100 │
970
- * │ 2020Feb 150
971
- * └──────┴───────┴─────────┘
1081
+ * >>> const df = $df.data({ year: [2020, 2020, 2021, 2021], month: ["Jan", "Feb", "Jan", "Feb"], revenue: [100, 150, 120, 180] })
1082
+ * >>> df
1083
+ * shape: (4, 3)
1084
+ * ┌──────┬───────┬─────────┐
1085
+ * │ year │ monthrevenue
1086
+ * ├──────┼───────┼─────────┤
1087
+ * │ 2020 │ Jan 100
1088
+ * │ 2020 │ Feb │ 150 │
1089
+ * 2021 Jan 120 │
1090
+ * 2021 │ Feb │ 180 │
1091
+ * └──────┴───────┴─────────┘
1092
+ * >>> df.unpivot({ idVars: "metric", valueVars: ["q1", "q2"], varName: "quarter", valueName: "val" })
1093
+ * shape: (4, 3)
1094
+ * ┌────────┬─────────┬─────┐
1095
+ * │ metricquarter val
1096
+ * ├────────┼─────────┼─────┤
1097
+ * │ sales │ q1 │ 100 │
1098
+ * │ sales │ q2 │ 120 │
1099
+ * │ clicks │ q1 │ 500 │
1100
+ * │ clicks │ q2 │ 600 │
1101
+ * └────────┴─────────┴─────┘
972
1102
  */
973
1103
  unpivot<U extends RowRecord = any>(config: UnpivotOptions<T>): DataFrame<U>;
974
1104
  /**
@@ -976,93 +1106,132 @@ export declare class DataFrame<T extends RowRecord = any> {
976
1106
  * @param {ConcatItem | ConcatItem[]} other Single DataFrame or array of DataFrames to append vertically.
977
1107
  * @returns {DataFrame}
978
1108
  * @example
979
- * >>> const df1 = $df.data({ a: [1] })
980
- * >>> df1
981
- * shape: (1, 1)
982
- * ┌───┐
983
- * │ a │
984
- * ├───┤
985
- * │ 1 │
986
- * └───┘
987
- * >>> const df2 = $df.data({ a: [2] })
1109
+ * >>> const df1 = $df.data({ a: [1, 2] })
1110
+ * >>> const df2 = $df.data({ b: [10, 20] })
1111
+ * >>> df1
1112
+ * shape: (2, 1)
1113
+ * ┌───┐
1114
+ * │ a │
1115
+ * ├───┤
1116
+ * │ 1 │
1117
+ * 2
1118
+ * └───┘
1119
+ * >>> df2
1120
+ * shape: (2, 1)
1121
+ * ┌────┐
1122
+ * │ b │
1123
+ * ├────┤
1124
+ * │ 10 │
1125
+ * │ 20 │
1126
+ * └────┘
988
1127
  * >>> df1.vstack(df2)
989
- * shape: (2, 1)
990
- * ┌───┐
991
- * │ a
992
- * ├───┤
993
- * │ 1
994
- * │ 2
995
- * └───┘
1128
+ * shape: (4, 1)
1129
+ * ┌──────┐
1130
+ * │ a
1131
+ * ├──────┤
1132
+ * │ 1
1133
+ * │ 2
1134
+ * │ null │
1135
+ * │ null │
1136
+ * └──────┘
996
1137
  */
997
1138
  vstack<U extends RowRecord = any>(other: ConcatItem | ConcatItem[]): DataFrame<U>;
998
1139
  /**
999
1140
  * Gets width (total column count) of the DataFrame.
1000
1141
  * @returns Number of columns.
1001
1142
  * @example
1002
- * >>> const df = $df.data({ a: [1], b: [2] })
1003
- * >>> df
1004
- * shape: (1, 2)
1005
- * ┌───┬───┐
1006
- * │ a │ b │
1007
- * ├───┼───┤
1008
- * │ 1 │ 2
1009
- * └───┴───┘
1143
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
1144
+ * >>> df
1145
+ * shape: (2, 2)
1146
+ * ┌───┬───┐
1147
+ * │ a │ b │
1148
+ * ├───┼───┤
1149
+ * │ 1 │ x
1150
+ * │ 2 │ y │
1151
+ * └───┴───┘
1010
1152
  * >>> df.width
1011
1153
  * 2
1012
1154
  */
1013
1155
  get width(): number;
1014
- private _normalizeArgs;
1015
1156
  /**
1016
1157
  * Adds new columns or updates existing ones using column expressions.
1017
1158
  * @param {(string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]} args Expressions or field objects defining column calculations.
1018
1159
  * @returns {DataFrame}
1019
1160
  * @example
1020
- * >>> const df = $df.data({ a: [1, 2] })
1021
- * >>> df
1022
- * shape: (2, 1)
1023
- * ┌───┐
1024
- * │ a │
1025
- * ├───┤
1026
- * │ 1 │
1027
- * │ 2 │
1028
- * └───┘
1029
- * >>> df.with_columns($df.col("a").add(10).alias("b"))
1030
- * shape: (2, 2)
1031
- * ┌───┬────┐
1032
- * │ a │ b
1033
- * ├───┼────┤
1034
- * │ 1 │ 11
1035
- * │ 2 │ 12
1036
- * └───┴────┘
1161
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
1162
+ * >>> df
1163
+ * shape: (2, 2)
1164
+ * ┌───┬───┐
1165
+ * │ a │ b │
1166
+ * ├───┼───┤
1167
+ * │ 1 │ x │
1168
+ * │ 2 │ y │
1169
+ * └───┴───┘
1170
+ * >>> df.withColumns($df.col("a").mul(10).alias("a_x10"))
1171
+ * shape: (2, 3)
1172
+ * ┌───┬───┬───────┐
1173
+ * │ a │ b a_x10 │
1174
+ * ├───┼───┼───────┤
1175
+ * │ 1 │ x 10 │
1176
+ * │ 2 │ y 20 │
1177
+ * └───┴───┴───────┘
1037
1178
  */
1038
- with_columns(...args: (string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]): DataFrame<any>;
1179
+ withColumns(...args: (string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]): DataFrame<any>;
1039
1180
  /**
1040
1181
  * Appends an incremental index column.
1041
1182
  * @param {string} [name] Name of index column (default "index").
1042
1183
  * @param {number} [offset] Starting numeric index offset (default 0).
1043
1184
  * @returns {DataFrame}
1044
1185
  * @example
1045
- * >>> const df = $df.data({ val: ["a", "b"] })
1046
- * >>> df
1047
- * shape: (2, 1)
1048
- * ┌─────┐
1049
- * │ val
1050
- * ├─────┤
1051
- * │ a
1052
- * │ b
1053
- * └─────┘
1054
- * >>> df.with_row_index("idx")
1055
- * shape: (2, 2)
1056
- * ┌─────┬─────┐
1057
- * │ idx │ val
1058
- * ├─────┼─────┤
1059
- * │ 0 │ a
1060
- * │ 1 │ b
1061
- * └─────┴─────┘
1186
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
1187
+ * >>> df
1188
+ * shape: (2, 2)
1189
+ * ┌───┬───┐
1190
+ * │ a b │
1191
+ * ├───┼───┤
1192
+ * │ 1 x │
1193
+ * │ 2 y │
1194
+ * └───┴───┘
1195
+ * >>> df.withRowIndex("idx")
1196
+ * shape: (2, 3)
1197
+ * ┌─────┬───┬───┐
1198
+ * │ idx │ a b │
1199
+ * ├─────┼───┼───┤
1200
+ * │ 0 │ 1 x │
1201
+ * │ 1 │ 2 y │
1202
+ * └─────┴───┴───┘
1203
+ */
1204
+ withRowIndex(name?: string, offset?: number): DataFrame<any>;
1205
+ /**
1206
+ * Writes DataFrame to CSV format string or file/stream target.
1207
+ * @note [Environment]: When `file` is provided as a string file path, execution requires a Node.js-compatible
1208
+ * environment with `fs` access. In browser environments, omit `file` to receive a string or supply a custom writable stream object.
1209
+ * @param {string | { write: (str: string) => void }} [file] Target file path or writable stream target (optional).
1210
+ * @param {WriteCSVOptions} [options] CSV formatting options.
1211
+ * @param {string} [options.delimiter] Column delimiter character (default `","`).
1212
+ * @param {boolean} [options.header] When `true` (default), includes column header row.
1213
+ * @param {string} [options.quoteChar] Character used to enclose fields containing special characters (default `'"'`).
1214
+ * @returns {string} CSV string output.
1215
+ * @example
1216
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
1217
+ * >>> df
1218
+ * shape: (2, 2)
1219
+ * ┌───┬───┐
1220
+ * │ a │ b │
1221
+ * ├───┼───┤
1222
+ * │ 1 │ x │
1223
+ * │ 2 │ y │
1224
+ * └───┴───┘
1225
+ * >>> df.writeCsv()
1226
+ * "a,b\n1,x"
1062
1227
  */
1063
- with_row_index(name?: string, offset?: number): DataFrame<any>;
1228
+ writeCsv(file?: string | {
1229
+ write: (str: string) => void;
1230
+ }, options?: WriteCSVOptions): string;
1064
1231
  /**
1065
1232
  * Writes DataFrame rows to JSON format string or file/stream target.
1233
+ * @note [Environment]: When `file` is provided as a string file path, execution requires a Node.js-compatible
1234
+ * environment with `fs` access. In browser environments, omit `file` to receive a string or supply a custom writable stream object.
1066
1235
  * @param {string | { write: (str: string) => void }} [file] Target file path or writable stream target (optional).
1067
1236
  * @param {WriteJSONOptions} [options] JSON formatting and replacer options.
1068
1237
  * @param {JSONFormat} [options.format] JSON output format structure (`"json"` or `"ndjson"`). Default `"json"`.
@@ -1089,41 +1258,19 @@ export declare class DataFrame<T extends RowRecord = any> {
1089
1258
  * @param {((this: any, k: string, v: any) => any) | (string | number)[] | null} [options.replacerOptions.replacer] Custom replacer function or array whitelist that runs first for pre-processing.
1090
1259
  * @returns {string} JSON string representation.
1091
1260
  * @example
1092
- * >>> const df = $df.data({ a: [1], b: ["x"] })
1093
- * >>> df
1094
- * shape: (1, 2)
1095
- * ┌───┬───┐
1096
- * │ a │ b │
1097
- * ├───┼───┤
1098
- * │ 1 │ x │
1099
- * └───┴───┘
1100
- * >>> df.write_json()
1261
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
1262
+ * >>> df
1263
+ * shape: (2, 2)
1264
+ * ┌───┬───┐
1265
+ * │ a │ b │
1266
+ * ├───┼───┤
1267
+ * │ 1 │ x │
1268
+ * │ 2 │ y │
1269
+ * └───┴───┘
1270
+ * >>> df.writeJson()
1101
1271
  * '[{"a":1,"b":"x"}]'
1102
1272
  */
1103
- write_json(file?: string | {
1273
+ writeJson(file?: string | {
1104
1274
  write: (str: string) => void;
1105
1275
  }, { format, replacerOptions }?: WriteJSONOptions): string;
1106
- /**
1107
- * Writes DataFrame to CSV format string or file/stream target.
1108
- * @param {string | { write: (str: string) => void }} [file] Target file path or writable stream target (optional).
1109
- * @param {WriteCSVOptions} [options] CSV formatting options.
1110
- * @param {string} [options.delimiter] Column delimiter character (default `","`).
1111
- * @param {boolean} [options.header] When `true` (default), includes column header row.
1112
- * @param {string} [options.quoteChar] Character used to enclose fields containing special characters (default `'"'`).
1113
- * @returns {string} CSV string output.
1114
- * @example
1115
- * >>> const df = $df.data({ a: [1], b: ["x"] })
1116
- * >>> df
1117
- * shape: (1, 2)
1118
- * ┌───┬───┐
1119
- * │ a │ b │
1120
- * ├───┼───┤
1121
- * │ 1 │ x │
1122
- * └───┴───┘
1123
- * >>> df.write_csv()
1124
- * "a,b\n1,x"
1125
- */
1126
- write_csv(file?: string | {
1127
- write: (str: string) => void;
1128
- }, options?: WriteCSVOptions): string;
1129
1276
  }