df-script 1.6.0 → 1.8.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 (58) hide show
  1. package/README.md +3 -1
  2. package/dist/api.d.ts +3 -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 +27 -12
  7. package/dist/columnExpressions/constants.d.ts +2 -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/duration.d.ts +33 -0
  11. package/dist/columnExpressions/functions/element.d.ts +25 -0
  12. package/dist/columnExpressions/functions/exclude.d.ts +24 -0
  13. package/dist/columnExpressions/functions/implode.d.ts +28 -0
  14. package/dist/columnExpressions/functions/lit.d.ts +27 -0
  15. package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
  16. package/dist/columnExpressions/functions/struct.d.ts +31 -0
  17. package/dist/columnExpressions/functions/when.d.ts +36 -6
  18. package/dist/columnExpressions/index.d.ts +2 -0
  19. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +334 -0
  20. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +609 -0
  21. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +533 -5
  22. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
  23. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
  24. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
  25. package/dist/columnExpressions/mixins/StringExpr.d.ts +656 -3
  26. package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
  27. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +588 -11
  28. package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
  29. package/dist/columnExpressions/types.d.ts +1 -0
  30. package/dist/columnExpressions/utils.d.ts +10 -0
  31. package/dist/constants.d.ts +15 -3
  32. package/dist/dataframe/dataframe.d.ts +1073 -3
  33. package/dist/dataframe/grouped/grouped.d.ts +41 -6
  34. package/dist/dataframe/types.d.ts +26 -3
  35. package/dist/dataframe/utils.d.ts +22 -1
  36. package/dist/datatypes/types.d.ts +51 -1
  37. package/dist/exceptions/index.d.ts +33 -0
  38. package/dist/exceptions/utils.d.ts +2 -0
  39. package/dist/functions/concat.d.ts +50 -0
  40. package/dist/functions/read_csv.d.ts +9 -0
  41. package/dist/functions/read_json.d.ts +7 -2
  42. package/dist/index.html +17 -0
  43. package/dist/index.js +6 -6
  44. package/dist/index.mjs +6 -0
  45. package/dist/types.d.ts +70 -14
  46. package/dist/utils/array.d.ts +55 -1
  47. package/dist/utils/csv.d.ts +1 -0
  48. package/dist/utils/date.d.ts +14 -27
  49. package/dist/utils/duration.d.ts +5 -0
  50. package/dist/utils/index.d.ts +1 -0
  51. package/dist/utils/json.d.ts +1 -0
  52. package/dist/utils/number.d.ts +1 -0
  53. package/dist/utils/object.d.ts +1 -0
  54. package/dist/utils/string.d.ts +12 -0
  55. package/package.json +28 -4
  56. package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
  57. package/dist/utils/guards.d.ts +0 -13
  58. package/dist/utils/list.d.ts +0 -217
@@ -1,58 +1,1128 @@
1
1
  import { GroupedData } from "./grouped/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, UnpivotOptions, TransposeOptions, WriteJSONOptions, WriteCSVOptions } from "./types";
3
+ import type { LimitOptions, SortOptions, PivotOptions, JoinOptions, AsofJoinOptions, UnpivotOptions, TransposeOptions, WriteJSONOptions, WriteCSVOptions } from "./types";
4
+ /**
5
+ * Two-dimensional columnar tabular data structure supporting expression execution and reshaping.
6
+ */
4
7
  export declare class DataFrame<T extends RowRecord = any> {
5
8
  _columns: DataFrameColumns<T>;
6
9
  private _height;
7
10
  private _schema;
8
11
  static _createDirect<U extends RowRecord = any>(columns: ColumnDict, schema: DataFrameSchema, height: number): DataFrame<U>;
12
+ /**
13
+ * Initializes a new DataFrame from row objects or a column dictionary.
14
+ * @param data Array of row objects or column data dictionary.
15
+ * @param schema Optional explicit DataFrame schema mapping.
16
+ * @param height Optional explicit height (row count).
17
+ * @namespace df
18
+ * @category DataFrame
19
+ * @syntax df.{symbol}(...)
20
+ * @example
21
+ * >>> const df = $df.data([{ a: 1, b: "x" }, { a: 2, b: "y" }])
22
+ * >>> df
23
+ * shape: (2, 2)
24
+ * ┌─────┬─────┐
25
+ * │ a │ b │
26
+ * ├─────┼─────┤
27
+ * │ 1 │ x │
28
+ * │ 2 │ y │
29
+ * └─────┴─────┘
30
+ */
9
31
  constructor(data: T[] | ColumnDict, schema?: DataFrameSchema, height?: number);
10
- private inferSchema;
11
- private applySchema;
32
+ private _inferSchema;
33
+ private _applySchema;
34
+ /**
35
+ * Gets array of column names in the DataFrame.
36
+ * @returns Array of column name strings.
37
+ * @example
38
+ * >>> const df = $df.data({ a: [1], b: [2] })
39
+ * >>> df
40
+ * shape: (1, 2)
41
+ * ┌───┬───┐
42
+ * │ a │ b │
43
+ * ├───┼───┤
44
+ * │ 1 │ 2 │
45
+ * └───┴───┘
46
+ * >>> df.columns
47
+ * ["a", "b"]
48
+ */
12
49
  get columns(): string[];
50
+ /**
51
+ * Concatenates items vertically, horizontally, or diagonally.
52
+ *
53
+ * @param {ConcatItem | ConcatItem[]} items Single DataFrame or array of DataFrames/rows to concatenate.
54
+ * @param {ConcatOptions} [options] Configuration options for concatenation layout and strictness.
55
+ * @param {ConcatHow} [options.how] Layout strategy: `"vertical"` (default, appends rows top-to-bottom), `"horizontal"` (joins unique columns side-by-side), or `"diagonal"` (concatenates mismatched columns with null padding).
56
+ * @param {boolean} [options.horizontal.strict] When `true` (default), throws an error if row counts mismatch in horizontal concatenation. Set `false` to pad shorter DataFrames with `null`.
57
+ * @returns {DataFrame}
58
+ *
59
+ * @example
60
+ * // 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] })
70
+ * >>> df1.concat(df2, { how: "vertical" })
71
+ * shape: (2, 1)
72
+ * ┌───┐
73
+ * │ a │
74
+ * ├───┤
75
+ * │ 1 │
76
+ * │ 2 │
77
+ * └───┘
78
+ *
79
+ * @example
80
+ * // 2. Horizontal Concatenation:
81
+ * >>> const df1 = $df.data({ a: [1] })
82
+ * >>> const df2 = $df.data({ b: [2] })
83
+ * >>> df1.concat(df2, { how: "horizontal" })
84
+ * shape: (1, 2)
85
+ * ┌───┬───┐
86
+ * │ a │ b │
87
+ * ├───┼───┤
88
+ * │ 1 │ 2 │
89
+ * └───┴───┘
90
+ *
91
+ * @example
92
+ * // 3. Diagonal Concatenation (mismatched columns):
93
+ * >>> const df1 = $df.data({ a: [1] })
94
+ * >>> const df2 = $df.data({ b: [2] })
95
+ * >>> df1.concat(df2, { how: "diagonal" })
96
+ * shape: (2, 2)
97
+ * ┌──────┬──────┐
98
+ * │ a │ b │
99
+ * ├──────┼──────┤
100
+ * │ 1 │ null │
101
+ * │ null │ 2 │
102
+ * └──────┴──────┘
103
+ *
104
+ */
13
105
  concat<U extends RowRecord = any>(items: ConcatItem | ConcatItem[], options?: ConcatOptions): DataFrame<U>;
106
+ /**
107
+ * Drops specified columns from the DataFrame.
108
+ * @param {(K | K[])[]} args Column names or arrays of column names to remove.
109
+ * @returns {DataFrame}
110
+ * @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
+ * └───┴───┘
119
+ * >>> df.drop("b")
120
+ * shape: (1, 1)
121
+ * ┌───┐
122
+ * │ a │
123
+ * ├───┤
124
+ * │ 1 │
125
+ * └───┘
126
+ */
14
127
  drop<K extends keyof T>(...args: (K | K[])[]): DataFrame<Omit<T, K>>;
128
+ /**
129
+ * Drops rows containing null or undefined values in specified subset columns.
130
+ * @param {string | string[]} [subset] Column name or array of column names to check for nulls.
131
+ * @returns {DataFrame}
132
+ * @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()
144
+ * shape: (2, 1)
145
+ * ┌───┐
146
+ * │ a │
147
+ * ├───┤
148
+ * │ 1 │
149
+ * │ 3 │
150
+ * └───┘
151
+ */
15
152
  drop_nulls(subset?: string | string[]): DataFrame<T>;
153
+ /**
154
+ * Gets array of registered column DataTypes matching current schema order.
155
+ * @returns Array of RegisteredDataType definitions.
156
+ * @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
+ * └───┴──────┘
165
+ * >>> df.dtypes
166
+ * [Float64, Utf8]
167
+ */
16
168
  get dtypes(): RegisteredDataType[];
169
+ /**
170
+ * Explodes an array column into multiple rows, replicating non-target row attributes.
171
+ * @param {IntoExpr | IntoExpr[]} columns Target column expression or array column name to explode.
172
+ * @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.
175
+ * @returns {DataFrame}
176
+ * @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
+ * └───────┴────────┘
185
+ * >>> df.explode("values")
186
+ * shape: (2, 2)
187
+ * ┌───────┬────────┐
188
+ * │ group │ values │
189
+ * ├───────┼────────┤
190
+ * │ A │ 1 │
191
+ * │ A │ 2 │
192
+ * └───────┴────────┘
193
+ */
17
194
  explode(columns: IntoExpr | IntoExpr[], options?: ExplodeOptions): DataFrame<any>;
195
+ /**
196
+ * Fills null values across columns using scalar values or statistical strategies.
197
+ * @param {FillNullOptions} [options] Configuration options for null replacement.
198
+ * @param {any} [options.value] Scalar replacement value or dict mapping column names to values.
199
+ * @param {FillNullStrategy} [options.strategy] Statistical filling strategy (`"zero"`, `"mean"`, `"min"`, `"max"`, `"forward"`, `"backward"`).
200
+ * @param {number} [options.limit] Maximum consecutive nulls to fill when using propagation strategies.
201
+ * @returns {DataFrame}
202
+ * @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 })
214
+ * shape: (3, 1)
215
+ * ┌───┐
216
+ * │ a │
217
+ * ├───┤
218
+ * │ 1 │
219
+ * │ 0 │
220
+ * │ 3 │
221
+ * └───┘
222
+ */
18
223
  fill_null(options?: FillNullOptions): DataFrame<T>;
224
+ /**
225
+ * Filters rows matching boolean column expressions or predicate callbacks.
226
+ * @param {(IExpr | ((row: T) => any))[]} exprs Expressions or predicate functions evaluated per row.
227
+ * @returns {DataFrame}
228
+ * @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
+ * └───┘
239
+ * >>> df.filter($df.col("a").gt(1))
240
+ * shape: (2, 1)
241
+ * ┌───┐
242
+ * │ a │
243
+ * ├───┤
244
+ * │ 2 │
245
+ * │ 3 │
246
+ * └───┘
247
+ */
19
248
  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
+ */
20
264
  get_schema(): DataFrameSchema;
265
+ /**
266
+ * Groups rows by key columns to prepare for aggregations.
267
+ * @param {K | K[]} keys Column name or array of key column names.
268
+ * @returns {GroupedData}
269
+ * @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"))
281
+ * shape: (2, 2)
282
+ * ┌─────┬─────┐
283
+ * │ cat │ sum │
284
+ * ├─────┼─────┤
285
+ * │ A │ 30 │
286
+ * │ B │ 30 │
287
+ * └─────┴─────┘
288
+ */
21
289
  groupby<K extends keyof T>(keys: K | K[]): GroupedData<T, K>;
290
+ /**
291
+ * Returns the first N rows as a new DataFrame.
292
+ * @param n Number of leading rows to slice (default 10).
293
+ * @returns DataFrame
294
+ * @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
+ * └───┘
306
+ * >>> df.head(2)
307
+ * shape: (2, 1)
308
+ * ┌───┐
309
+ * │ a │
310
+ * ├───┤
311
+ * │ 1 │
312
+ * │ 2 │
313
+ * └───┘
314
+ */
22
315
  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
+ /**
346
+ * Gets height (total row count) of the DataFrame.
347
+ * @returns Number of rows.
348
+ * @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
+ * └────┘
359
+ * >>> df.height
360
+ * 3
361
+ */
23
362
  get height(): number;
363
+ /**
364
+ * Concatenates columns horizontally to the current DataFrame.
365
+ * @param {ConcatItem | ConcatItem[]} other DataFrame or array of DataFrames to append side-by-side.
366
+ * @param {HorizontalConcatOptions} [options] Horizontal concat configuration options.
367
+ * @param {boolean} [options.strict] When `true` (default), throws an error if row counts mismatch. Set `false` to allow null padding.
368
+ * @returns {DataFrame}
369
+ * @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] })
380
+ * >>> df1.hstack(df2)
381
+ * shape: (2, 2)
382
+ * ┌───┬────┐
383
+ * │ a │ b │
384
+ * ├───┼────┤
385
+ * │ 1 │ 10 │
386
+ * │ 2 │ 20 │
387
+ * └───┴────┘
388
+ */
24
389
  hstack<U extends RowRecord = any>(other: ConcatItem | ConcatItem[], options?: HorizontalConcatOptions): DataFrame<U>;
390
+ /**
391
+ * Inserts a new column at a specific ordinal index position.
392
+ * @param {number} index Target column index position.
393
+ * @param {string} name Name of the inserted column.
394
+ * @param {IntoExpr} expr Value expression or column definition.
395
+ * @returns {DataFrame}
396
+ * @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
+ * └───┴───┴───┘
412
+ */
25
413
  insert_column(index: number, name: string, expr: IntoExpr): DataFrame<any>;
414
+ /**
415
+ * Retrieves a single scalar cell value by row and column position or name.
416
+ * @param {number} [row] Row index position.
417
+ * @param {number | string} [column] Column index or column name string.
418
+ * @returns {any} Cell scalar value.
419
+ * @throws {DataFrameError} If shape is not (1, 1) when called without arguments.
420
+ * @throws {ShapeError} If row or column index is out of bounds.
421
+ * @example
422
+ * >>> const df = $df.data({ val: [42] })
423
+ * >>> df
424
+ * shape: (1, 1)
425
+ * ┌─────┐
426
+ * │ val │
427
+ * ├─────┤
428
+ * │ 42 │
429
+ * └─────┘
430
+ * >>> df.item(0, "val")
431
+ * 42
432
+ */
26
433
  item(row?: number, column?: number | string): any;
434
+ /**
435
+ * Yields a generator iterating over raw column arrays.
436
+ * @returns Generator of ColumnData arrays.
437
+ * @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])
450
+ */
27
451
  iter_columns(): Generator<ColumnData>;
452
+ /**
453
+ * Yields a generator iterating over rows as tuples or named objects.
454
+ * @param [config] Iteration format configuration.
455
+ * @param [config.named] When `true`, yields row objects with column keys (`{ col: val }`). When `false` (default), yields positional arrays (`[val1, val2]`).
456
+ * @returns Generator of rows.
457
+ * @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" }
470
+ */
28
471
  iter_rows({ named }?: {
29
472
  named?: boolean;
30
473
  }): Generator<any[] | Record<string, any>>;
474
+ /**
475
+ * 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"`.
482
+ * - `"inner"` — Only rows with matching keys in both DataFrames.
483
+ * - `"left"` — All left rows; unmatched right values are `null`.
484
+ * - `"right"` — All right rows; unmatched left values are `null`.
485
+ * - `"outer"` — All rows from both sides; unmatched values are `null`.
486
+ * - `"semi"` — Left rows that have a match in the right DataFrame (only left columns retained).
487
+ * - `"anti"` — Left rows that have **no** match in the right DataFrame (only left columns retained).
488
+ * - `"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
490
+ * 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
492
+ * 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"`.
495
+ * - `"none"` (or `false`) — No specific ordering is desired.
496
+ * - `"left"` (or `true`) — Preserves the order of the left DataFrame.
497
+ * - `"right"` — Preserves the order of the right DataFrame.
498
+ * - `"left_right"` — Preserves the order of the left DataFrame first, then the right.
499
+ * - `"right_left"` — Preserves the order of the right DataFrame first, then the left.
500
+ * @returns {DataFrame}
501
+ * @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
+ * │ 2 │ b │
510
+ * └────┴─────┘
511
+ * >>> const df2 = $df.data({ id: [1, 2], num: [100, 200] })
512
+ * >>> df1.join({ other: df2, on: "id" })
513
+ * shape: (2, 3)
514
+ * ┌────┬─────┬─────┐
515
+ * │ id │ val │ num │
516
+ * ├────┼─────┼─────┤
517
+ * │ 1 │ a │ 100 │
518
+ * │ 2 │ b │ 200 │
519
+ * └────┴─────┴─────┘
520
+ */
31
521
  join<U extends RowRecord = any, R extends RowRecord = any>(config: JoinOptions<T, U>): DataFrame<R>;
522
+ /**
523
+ * Performs an asof (as-of) join for inexact matching on ordered numeric or temporal key columns.
524
+ *
525
+ * Similar to a left join, but instead of exact key equality, matches the nearest key row from the right
526
+ * DataFrame according to the selected `strategy` ("backward", "forward", or "nearest") and optional `tolerance`.
527
+ * Both DataFrames must be sorted in ascending order on their respective `on` / `leftOn` / `rightOn` join keys.
528
+ *
529
+ * @param {AsofJoinOptions} options Asof join configuration options.
530
+ * @param {DataFrame} options.other The right DataFrame to join with.
531
+ * @param {string} [options.on] Column name to join on (must exist in both DataFrames and be sorted ascending).
532
+ * @param {string} [options.leftOn] Left DataFrame join key column name.
533
+ * @param {string} [options.rightOn] Right DataFrame join key column name.
534
+ * @param {string | string[]} [options.by] Optional exact-match group column(s) present in both DataFrames.
535
+ * @param {string | string[]} [options.leftBy] Group column(s) for exact key matching in left DataFrame.
536
+ * @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"`.
538
+ * - `"backward"` — Matches the latest right row where `rightKey <= leftKey`.
539
+ * - `"forward"` — Matches the earliest right row where `rightKey >= leftKey`.
540
+ * - `"nearest"` — Matches the right row with the absolute nearest key value to `leftKey`.
541
+ * @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`.
543
+ * @param {[string, string]} [options.suffixes] Column name suffixes `[leftSuffix, rightSuffix]` to resolve name collisions. Default `["", "_right"]`.
544
+ * @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`.
546
+ * @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
+ * @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
584
+ * 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
+ * └──────┴────────┴───────┴──────┘
592
+ */
593
+ join_asof<U extends RowRecord = any, R extends RowRecord = any>(options: AsofJoinOptions<T, U>): DataFrame<R>;
594
+ /**
595
+ * Limits the output to N rows starting from offset.
596
+ * @param {number} n Maximum number of rows to take.
597
+ * @param {LimitOptions} [options] Offset and slice direction options.
598
+ * @param {number} [options.offset] Number of rows to skip before taking `n` rows (default 0).
599
+ * @param {LimitPosition} [options.from] Slice direction starting point (`"start"` or `"end"`). Default `"start"`.
600
+ * @returns {DataFrame}
601
+ * @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
+ * └────┘
613
+ * >>> df.limit(2, { offset: 1 })
614
+ * shape: (2, 1)
615
+ * ┌────┐
616
+ * │ a │
617
+ * ├────┤
618
+ * │ 20 │
619
+ * │ 30 │
620
+ * └────┘
621
+ */
32
622
  limit(n: number, { offset, from }?: LimitOptions): DataFrame<T>;
623
+ /**
624
+ * Pivots columns from long format to a wide datagrid structure.
625
+ * @param config Pivot table configuration options.
626
+ * @param {string | string[]} config.index Key column(s) to use as new DataFrame rows.
627
+ * @param {string} config.columns Column whose distinct values become new wide column headers.
628
+ * @param {string} config.values Column whose cell values populate the pivoted grid cells.
629
+ * @param {AggFn | string} [config.agg] Aggregation function to apply when multiple values exist for a cell.
630
+ * @returns DataFrame
631
+ * @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
+ * │ year │ month │ revenue │
641
+ * ├──────┼───────┼─────────┤
642
+ * │ 2020 │ Jan │ 100 │
643
+ * │ 2020 │ Feb │ 150 │
644
+ * │ 2021 │ Jan │ 120 │
645
+ * │ 2021 │ Feb │ 180 │
646
+ * └──────┴───────┴─────────┘
647
+ * >>> df.pivot({ index: "year", columns: "month", values: "revenue" })
648
+ * shape: (2, 3)
649
+ * ┌──────┬─────┬─────┐
650
+ * │ year │ Jan │ Feb │
651
+ * ├──────┼─────┼─────┤
652
+ * │ 2020 │ 100 │ 150 │
653
+ * │ 2021 │ 120 │ 180 │
654
+ * └──────┴─────┴─────┘
655
+ */
33
656
  pivot<U extends RowRecord = any>(config: PivotOptions<T>): DataFrame<U>;
657
+ /**
658
+ * Renames columns based on a key-value mapping dictionary.
659
+ * @param {Partial<Record<keyof T, string>>} [mapping] Dictionary mapping old column names to new names.
660
+ * @returns {DataFrame}
661
+ * @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
+ * └──────────┘
677
+ */
34
678
  rename(mapping?: Partial<Record<keyof T, string>>): DataFrame<any>;
679
+ /**
680
+ * Reverses the row ordering of the DataFrame.
681
+ * @returns DataFrame
682
+ * @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
+ * └───┘
693
+ * >>> df.reverse()
694
+ * shape: (3, 1)
695
+ * ┌───┐
696
+ * │ a │
697
+ * ├───┤
698
+ * │ 3 │
699
+ * │ 2 │
700
+ * │ 1 │
701
+ * └───┘
702
+ */
35
703
  reverse(): DataFrame<T>;
704
+ /**
705
+ * Gets current DataFrameSchema dictionary mapping column names to DataType.
706
+ * @returns DataFrameSchema mapping.
707
+ * @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
+ * └───┴──────┘
716
+ * >>> df.schema
717
+ * { a: Float64, b: Utf8 }
718
+ */
36
719
  get schema(): DataFrameSchema;
720
+ /**
721
+ * Selects specific columns or evaluates column expressions.
722
+ * @param {(string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]} args Column names, column expressions, or object maps to evaluate.
723
+ * @returns {DataFrame}
724
+ * @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
+ * └───┴────┘
734
+ * >>> df.select("a", $df.col("b").add(100).alias("b_plus"))
735
+ * shape: (2, 2)
736
+ * ┌───┬────────┐
737
+ * │ a │ b_plus │
738
+ * ├───┼────────┤
739
+ * │ 1 │ 110 │
740
+ * │ 2 │ 120 │
741
+ * └───┴────────┘
742
+ */
37
743
  select<U extends RowRecord = any>(...args: (string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]): DataFrame<U>;
744
+ /**
745
+ * Gets DataFrame dimensions as [height, width] tuple.
746
+ * @returns Tuple [height, width].
747
+ * @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
+ * └───┴───┘
757
+ * >>> df.shape
758
+ * [2, 2]
759
+ */
38
760
  get shape(): [number, number];
761
+ /**
762
+ * Slices a subset range of rows between start and end index.
763
+ * @param {number} start Starting row index.
764
+ * @param {number} [end] Optional ending row index (exclusive).
765
+ * @returns {DataFrame}
766
+ * @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
+ * └────┘
778
+ * >>> df.slice(1, 3)
779
+ * shape: (2, 1)
780
+ * ┌────┐
781
+ * │ a │
782
+ * ├────┤
783
+ * │ 20 │
784
+ * │ 30 │
785
+ * └────┘
786
+ */
39
787
  slice(start: number, end?: number): DataFrame<T>;
788
+ /**
789
+ * Sorts DataFrame rows by one or more column expressions or custom sorters.
790
+ * @param {SortOptions<T>} [config] Sort configuration options.
791
+ * @param {keyof T | (keyof T)[] | IExpr | IExpr[]} config.by Column name(s) or expression(s) to sort by.
792
+ * @param {boolean | boolean[]} [config.descending] Sort order boolean or array of booleans per key (default `false`).
793
+ * @param {boolean} [config.nullsLast] When `true` (default), places nulls at the end of sorted output.
794
+ * @param {Partial<Record<keyof T, (a: any, b: any) => number>>} [config.custom] Optional dictionary mapping column names to custom comparator functions.
795
+ * @returns {DataFrame}
796
+ * @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
+ * └─────┘
816
+ */
40
817
  sort(config?: SortOptions<T>): DataFrame<T>;
818
+ /**
819
+ * Returns the last N rows as a new DataFrame.
820
+ * @param n Number of trailing rows to take (default 10).
821
+ * @returns DataFrame
822
+ * @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
+ * └───┘
834
+ * >>> df.tail(2)
835
+ * shape: (2, 1)
836
+ * ┌───┐
837
+ * │ a │
838
+ * ├───┤
839
+ * │ 3 │
840
+ * │ 4 │
841
+ * └───┘
842
+ */
41
843
  tail(n?: number): DataFrame<T>;
844
+ /**
845
+ * Converts columns into a JavaScript dictionary mapping column keys to raw arrays.
846
+ * @returns Column dictionary map.
847
+ * @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()
858
+ * { a: Float64Array([1, 2]), b: ["x", "y"] }
859
+ */
42
860
  to_dict(): DataFrameColumns<T>;
861
+ /**
862
+ * Converts rows into an array of JavaScript objects.
863
+ * @returns Array of row record objects.
864
+ * @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()
874
+ * [{ a: 1, b: "x" }]
875
+ */
43
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
+ */
44
894
  to_array<K extends keyof T>(nameOrExpr: K | IExpr): any[];
895
+ /**
896
+ * Transposes rows into columns and columns into rows.
897
+ * @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.
901
+ * @returns {DataFrame}
902
+ * @example
903
+ * >>> const df = $df.data({ metric: ["sales", "clicks"], q1: [100, 500], q2: [120, 600] })
904
+ * >>> df
905
+ * shape: (2, 3)
906
+ * ┌────────┬─────┬─────┐
907
+ * │ metric │ q1 │ q2 │
908
+ * ├────────┼─────┼─────┤
909
+ * │ sales │ 100 │ 120 │
910
+ * │ clicks │ 500 │ 600 │
911
+ * └────────┴─────┴─────┘
912
+ * >>> df.transpose({ include_header: true, header_name: "metric" })
913
+ * shape: (2, 3)
914
+ * ┌────────┬──────────┬──────────┐
915
+ * │ metric │ column_0 │ column_1 │
916
+ * ├────────┼──────────┼──────────┤
917
+ * │ q1 │ 100 │ 500 │
918
+ * │ q2 │ 120 │ 600 │
919
+ * └────────┴──────────┴──────────┘
920
+ */
45
921
  transpose({ include_header: includeHeader, header_name: headerName, column_names: colNamesOpt }?: TransposeOptions): DataFrame<any>;
922
+ /**
923
+ * Filters distinct unique rows matching target key columns.
924
+ * @param {K | K[]} [columns] Target column or array of column names to evaluate uniqueness.
925
+ * @returns {DataFrame}
926
+ * @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
+ * └───┴───┘
937
+ * >>> df.unique()
938
+ * shape: (2, 2)
939
+ * ┌───┬───┐
940
+ * │ a │ b │
941
+ * ├───┼───┤
942
+ * │ 1 │ x │
943
+ * │ 2 │ y │
944
+ * └───┴───┘
945
+ */
46
946
  unique<K extends keyof T>(columns?: K | K[]): DataFrame<T>;
947
+ /**
948
+ * Unpivots a wide DataFrame into a long format structure.
949
+ * @param {UnpivotOptions<T>} config Unpivot configuration options.
950
+ * @param {keyof T | (keyof T)[]} config.idVars Key column(s) to retain as identifier variables.
951
+ * @param {keyof T | (keyof T)[]} config.valueVars Column(s) to unpivot into variable-value pairs.
952
+ * @param {string} [config.varName] Name for the new variable column holding old column headers (default `"variable"`).
953
+ * @param {string} [config.valueName] Name for the new value column holding cell values (default `"value"`).
954
+ * @returns {DataFrame}
955
+ * @example
956
+ * >>> const df = $df.data({ year: [2020], Jan: [100], Feb: [150] })
957
+ * >>> df
958
+ * shape: (1, 3)
959
+ * ┌──────┬─────┬─────┐
960
+ * │ year │ Jan │ Feb │
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
+ * │ 2020 │ Feb │ 150 │
971
+ * └──────┴───────┴─────────┘
972
+ */
47
973
  unpivot<U extends RowRecord = any>(config: UnpivotOptions<T>): DataFrame<U>;
974
+ /**
975
+ * Concatenates DataFrames vertically. Alias for concat({ how: "vertical" }).
976
+ * @param {ConcatItem | ConcatItem[]} other Single DataFrame or array of DataFrames to append vertically.
977
+ * @returns {DataFrame}
978
+ * @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] })
988
+ * >>> df1.vstack(df2)
989
+ * shape: (2, 1)
990
+ * ┌───┐
991
+ * │ a │
992
+ * ├───┤
993
+ * │ 1 │
994
+ * │ 2 │
995
+ * └───┘
996
+ */
48
997
  vstack<U extends RowRecord = any>(other: ConcatItem | ConcatItem[]): DataFrame<U>;
998
+ /**
999
+ * Gets width (total column count) of the DataFrame.
1000
+ * @returns Number of columns.
1001
+ * @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
+ * └───┴───┘
1010
+ * >>> df.width
1011
+ * 2
1012
+ */
49
1013
  get width(): number;
50
1014
  private _normalizeArgs;
1015
+ /**
1016
+ * Adds new columns or updates existing ones using column expressions.
1017
+ * @param {(string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]} args Expressions or field objects defining column calculations.
1018
+ * @returns {DataFrame}
1019
+ * @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
+ * └───┴────┘
1037
+ */
51
1038
  with_columns(...args: (string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]): DataFrame<any>;
1039
+ /**
1040
+ * Appends an incremental index column.
1041
+ * @param {string} [name] Name of index column (default "index").
1042
+ * @param {number} [offset] Starting numeric index offset (default 0).
1043
+ * @returns {DataFrame}
1044
+ * @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
+ * └─────┴─────┘
1062
+ */
52
1063
  with_row_index(name?: string, offset?: number): DataFrame<any>;
1064
+ /**
1065
+ * Writes DataFrame rows to JSON format string or file/stream target.
1066
+ * @param {string | { write: (str: string) => void }} [file] Target file path or writable stream target (optional).
1067
+ * @param {WriteJSONOptions} [options] JSON formatting and replacer options.
1068
+ * @param {JSONFormat} [options.format] JSON output format structure (`"json"` or `"ndjson"`). Default `"json"`.
1069
+ * @param {SafeJsonReplacerOptions} [options.replacerOptions] Serialization options for custom type handling.
1070
+ * @param {(v: Date) => string} [options.replacerOptions.formatDate] Custom formatter function for Date objects. Ignored if `onDate` is specified.
1071
+ * @param {"string" | "number"} [options.replacerOptions.bigintStrategy] Convert BigInts to numeric strings or numbers if safe. Default `"string"`.
1072
+ * @param {(v: bigint) => any} [options.replacerOptions.onBigInt] Custom serialization override for BigInt values.
1073
+ * @param {(v: any) => any} [options.replacerOptions.onTypedArray] Custom serialization override for TypedArray values.
1074
+ * @param {(v: Set<any>) => any} [options.replacerOptions.onSet] Custom serialization override for Set objects.
1075
+ * @param {(v: Map<any, any>) => any} [options.replacerOptions.onMap] Custom serialization override for Map objects.
1076
+ * @param {(v: RegExp) => any} [options.replacerOptions.onRegExp] Custom serialization override for RegExp objects.
1077
+ * @param {(v: Date) => any} [options.replacerOptions.onDate] Custom serialization override for Date objects. Takes precedence over `formatDate`.
1078
+ * @param {(v: Error) => any} [options.replacerOptions.onError] Custom serialization override for Error objects. Prevents empty `{}` output.
1079
+ * @param {(v: URLSearchParams) => any} [options.replacerOptions.onURLSearchParams] Custom serialization override for URLSearchParams objects.
1080
+ * @param {(this: any, k: string, v: any) => any} [options.replacerOptions.onCustom] Catch-all serialization override for custom types. Runs after native type checks.
1081
+ * @param {boolean} [options.replacerOptions.handleCircular] If `true`, handles circular references by replacing them instead of throwing.
1082
+ * @param {(this: any, k: string, v: any) => any} [options.replacerOptions.onCircular] Custom fallback when a circular reference is found. Default `"[Circular]"`.
1083
+ * @param {boolean} [options.replacerOptions.voidBigIntReplacement] If `true`, disables the default safe serialization for BigInt values.
1084
+ * @param {boolean} [options.replacerOptions.voidTypedArrayReplacement] If `true`, disables the default safe serialization for TypedArray values.
1085
+ * @param {boolean} [options.replacerOptions.voidSetReplacement] If `true`, disables the default safe serialization for Set objects.
1086
+ * @param {boolean} [options.replacerOptions.voidMapReplacement] If `true`, disables the default safe serialization for Map objects.
1087
+ * @param {boolean} [options.replacerOptions.voidRegExpReplacement] If `true`, disables the default safe serialization for RegExp objects.
1088
+ * @param {boolean} [options.replacerOptions.voidDateReplacement] If `true`, disables the default safe serialization for Date objects.
1089
+ * @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
+ * @returns {string} JSON string representation.
1091
+ * @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()
1101
+ * '[{"a":1,"b":"x"}]'
1102
+ */
53
1103
  write_json(file?: string | {
54
1104
  write: (str: string) => void;
55
1105
  }, { 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
+ */
56
1126
  write_csv(file?: string | {
57
1127
  write: (str: string) => void;
58
1128
  }, options?: WriteCSVOptions): string;