df-script 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +125 -9
  2. package/dist/api.d.ts +3 -2
  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 +14 -7
  6. package/dist/columnExpressions/ExprBase.d.ts +26 -12
  7. package/dist/columnExpressions/constants.d.ts +1 -0
  8. package/dist/columnExpressions/functions/all.d.ts +23 -0
  9. package/dist/columnExpressions/functions/coalesce.d.ts +31 -2
  10. package/dist/columnExpressions/functions/element.d.ts +26 -1
  11. package/dist/columnExpressions/functions/exclude.d.ts +24 -0
  12. package/dist/columnExpressions/functions/implode.d.ts +28 -0
  13. package/dist/columnExpressions/functions/lit.d.ts +27 -0
  14. package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
  15. package/dist/columnExpressions/functions/struct.d.ts +31 -0
  16. package/dist/columnExpressions/functions/when.d.ts +38 -8
  17. package/dist/columnExpressions/index.d.ts +2 -1
  18. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +336 -2
  19. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +620 -10
  20. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +567 -0
  21. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
  22. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
  23. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
  24. package/dist/columnExpressions/mixins/StringExpr.d.ts +658 -5
  25. package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
  26. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +530 -4
  27. package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
  28. package/dist/columnExpressions/types.d.ts +2 -0
  29. package/dist/constants.d.ts +11 -0
  30. package/dist/dataframe/dataframe.d.ts +933 -3
  31. package/dist/dataframe/grouped/grouped.d.ts +41 -6
  32. package/dist/dataframe/types.d.ts +1 -0
  33. package/dist/dataframe/utils.d.ts +1 -0
  34. package/dist/datatypes/index.d.ts +3 -2
  35. package/dist/datatypes/types.d.ts +52 -7
  36. package/dist/exceptions/index.d.ts +23 -0
  37. package/dist/functions/concat.d.ts +50 -0
  38. package/dist/functions/read_csv.d.ts +9 -0
  39. package/dist/functions/read_json.d.ts +7 -2
  40. package/dist/index.html +17 -0
  41. package/dist/index.js +6 -6
  42. package/dist/index.mjs +6 -0
  43. package/dist/types.d.ts +51 -16
  44. package/dist/utils/{list.d.ts → array.d.ts} +68 -15
  45. package/dist/utils/binary.d.ts +3 -0
  46. package/dist/utils/csv.d.ts +1 -0
  47. package/dist/utils/date.d.ts +23 -54
  48. package/dist/utils/index.d.ts +3 -2
  49. package/dist/utils/json.d.ts +1 -0
  50. package/dist/utils/number.d.ts +15 -29
  51. package/dist/utils/object.d.ts +27 -0
  52. package/dist/utils/string.d.ts +15 -5
  53. package/package.json +18 -4
  54. package/dist/api.js +0 -26
  55. package/dist/bundle.min.js +0 -1
  56. package/dist/columnExpressions/ColumnExpr.js +0 -219
  57. package/dist/columnExpressions/ExprBase.js +0 -92
  58. package/dist/columnExpressions/constants.js +0 -7
  59. package/dist/columnExpressions/functions/all.js +0 -11
  60. package/dist/columnExpressions/functions/coalesce.js +0 -44
  61. package/dist/columnExpressions/functions/element.js +0 -11
  62. package/dist/columnExpressions/functions/exclude.js +0 -13
  63. package/dist/columnExpressions/functions/implode.js +0 -7
  64. package/dist/columnExpressions/functions/lit.js +0 -17
  65. package/dist/columnExpressions/functions/repeat.d.ts +0 -47
  66. package/dist/columnExpressions/functions/repeat.js +0 -131
  67. package/dist/columnExpressions/functions/seq_range.js +0 -91
  68. package/dist/columnExpressions/functions/when.js +0 -85
  69. package/dist/columnExpressions/index.js +0 -38
  70. package/dist/columnExpressions/mixins/AggregationExpr.js +0 -76
  71. package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -131
  72. package/dist/columnExpressions/mixins/BooleanExpr.d.ts +0 -40
  73. package/dist/columnExpressions/mixins/BooleanExpr.js +0 -67
  74. package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -250
  75. package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
  76. package/dist/columnExpressions/mixins/ListExpr.js +0 -224
  77. package/dist/columnExpressions/mixins/LogicalExpr.js +0 -53
  78. package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -71
  79. package/dist/columnExpressions/mixins/NumericExpr.d.ts +0 -92
  80. package/dist/columnExpressions/mixins/NumericExpr.js +0 -259
  81. package/dist/columnExpressions/mixins/StringExpr.js +0 -237
  82. package/dist/columnExpressions/mixins/StructExpr.js +0 -139
  83. package/dist/columnExpressions/mixins/TemporalExpr.js +0 -126
  84. package/dist/columnExpressions/mixins/WindowExpr.js +0 -151
  85. package/dist/columnExpressions/types.js +0 -2
  86. package/dist/columnExpressions/utils.js +0 -45
  87. package/dist/dataframe/constants.js +0 -7
  88. package/dist/dataframe/dataframe.js +0 -990
  89. package/dist/dataframe/grouped/grouped.js +0 -114
  90. package/dist/dataframe/index.js +0 -20
  91. package/dist/dataframe/types.js +0 -2
  92. package/dist/dataframe/utils.js +0 -307
  93. package/dist/datatypes/DataType.js +0 -76
  94. package/dist/datatypes/index.js +0 -46
  95. package/dist/datatypes/types/Binary.d.ts +0 -9
  96. package/dist/datatypes/types/Binary.js +0 -18
  97. package/dist/datatypes/types/Boolean.d.ts +0 -9
  98. package/dist/datatypes/types/Boolean.js +0 -19
  99. package/dist/datatypes/types/Date.d.ts +0 -8
  100. package/dist/datatypes/types/Date.js +0 -21
  101. package/dist/datatypes/types/Datetime.d.ts +0 -8
  102. package/dist/datatypes/types/Datetime.js +0 -17
  103. package/dist/datatypes/types/Decimal.d.ts +0 -10
  104. package/dist/datatypes/types/Decimal.js +0 -28
  105. package/dist/datatypes/types/Duration.d.ts +0 -8
  106. package/dist/datatypes/types/Duration.js +0 -17
  107. package/dist/datatypes/types/Float32.d.ts +0 -8
  108. package/dist/datatypes/types/Float32.js +0 -17
  109. package/dist/datatypes/types/Float64.d.ts +0 -8
  110. package/dist/datatypes/types/Float64.js +0 -17
  111. package/dist/datatypes/types/Int16.d.ts +0 -8
  112. package/dist/datatypes/types/Int16.js +0 -17
  113. package/dist/datatypes/types/Int32.d.ts +0 -8
  114. package/dist/datatypes/types/Int32.js +0 -17
  115. package/dist/datatypes/types/Int64.d.ts +0 -8
  116. package/dist/datatypes/types/Int64.js +0 -17
  117. package/dist/datatypes/types/Int8.d.ts +0 -8
  118. package/dist/datatypes/types/Int8.js +0 -17
  119. package/dist/datatypes/types/List.d.ts +0 -10
  120. package/dist/datatypes/types/List.js +0 -31
  121. package/dist/datatypes/types/Null.d.ts +0 -9
  122. package/dist/datatypes/types/Null.js +0 -17
  123. package/dist/datatypes/types/Object.d.ts +0 -9
  124. package/dist/datatypes/types/Object.js +0 -17
  125. package/dist/datatypes/types/Struct.d.ts +0 -14
  126. package/dist/datatypes/types/Struct.js +0 -39
  127. package/dist/datatypes/types/Time.d.ts +0 -8
  128. package/dist/datatypes/types/Time.js +0 -29
  129. package/dist/datatypes/types/UInt16.d.ts +0 -8
  130. package/dist/datatypes/types/UInt16.js +0 -17
  131. package/dist/datatypes/types/UInt32.d.ts +0 -8
  132. package/dist/datatypes/types/UInt32.js +0 -17
  133. package/dist/datatypes/types/UInt64.d.ts +0 -8
  134. package/dist/datatypes/types/UInt64.js +0 -17
  135. package/dist/datatypes/types/UInt8.d.ts +0 -8
  136. package/dist/datatypes/types/UInt8.js +0 -17
  137. package/dist/datatypes/types/Utf8.d.ts +0 -10
  138. package/dist/datatypes/types/Utf8.js +0 -20
  139. package/dist/datatypes/types.js +0 -290
  140. package/dist/exceptions/index.js +0 -46
  141. package/dist/exceptions/utils.js +0 -28
  142. package/dist/functions/concat.js +0 -260
  143. package/dist/functions/index.js +0 -9
  144. package/dist/functions/read_csv.js +0 -53
  145. package/dist/functions/read_json.js +0 -21
  146. package/dist/functions/transpose.d.ts +0 -7
  147. package/dist/functions/transpose.js +0 -84
  148. package/dist/types.js +0 -2
  149. package/dist/utils/boolean.d.ts +0 -1
  150. package/dist/utils/boolean.js +0 -18
  151. package/dist/utils/csv.js +0 -313
  152. package/dist/utils/date.js +0 -348
  153. package/dist/utils/guards.d.ts +0 -12
  154. package/dist/utils/guards.js +0 -112
  155. package/dist/utils/index.js +0 -23
  156. package/dist/utils/json.js +0 -217
  157. package/dist/utils/list.js +0 -361
  158. package/dist/utils/number.js +0 -401
  159. package/dist/utils/string.js +0 -209
@@ -1,58 +1,988 @@
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
3
  import type { LimitOptions, SortOptions, PivotOptions, JoinOptions, 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 items Single DataFrame or array of DataFrames/rows to concatenate.
54
+ * @param [options] Configuration options for concatenation layout and strictness.
55
+ * @param [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 [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 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 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 columns Target column expression or array column name to explode.
172
+ * @param [options] Configuration options for empty array and null handling.
173
+ * @param [options.empty_as_null] When `true`, converts empty arrays to `null` rows.
174
+ * @param [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 [options] Configuration options for null replacement.
198
+ * @param [options.value] Scalar replacement value or dict mapping column names to values.
199
+ * @param [options.strategy] Statistical filling strategy (`"zero"`, `"mean"`, `"min"`, `"max"`, `"forward"`, `"backward"`).
200
+ * @param [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 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 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
+ * Gets height (total row count) of the DataFrame.
318
+ * @returns Number of rows.
319
+ * @example
320
+ * >>> const df = $df.data({ a: [10, 20, 30] })
321
+ * >>> df
322
+ * shape: (3, 1)
323
+ * ┌────┐
324
+ * │ a │
325
+ * ├────┤
326
+ * │ 10 │
327
+ * │ 20 │
328
+ * │ 30 │
329
+ * └────┘
330
+ * >>> df.height
331
+ * 3
332
+ */
23
333
  get height(): number;
334
+ /**
335
+ * Concatenates columns horizontally to the current DataFrame.
336
+ * @param other DataFrame or array of DataFrames to append side-by-side.
337
+ * @param [options] Horizontal concat configuration options.
338
+ * @param [options.strict] When `true` (default), throws an error if row counts mismatch. Set `false` to allow null padding.
339
+ * @returns DataFrame
340
+ * @example
341
+ * >>> const df1 = $df.data({ a: [1, 2] })
342
+ * >>> df1
343
+ * shape: (2, 1)
344
+ * ┌───┐
345
+ * │ a │
346
+ * ├───┤
347
+ * │ 1 │
348
+ * │ 2 │
349
+ * └───┘
350
+ * >>> const df2 = $df.data({ b: [10, 20] })
351
+ * >>> df1.hstack(df2)
352
+ * shape: (2, 2)
353
+ * ┌───┬────┐
354
+ * │ a │ b │
355
+ * ├───┼────┤
356
+ * │ 1 │ 10 │
357
+ * │ 2 │ 20 │
358
+ * └───┴────┘
359
+ */
24
360
  hstack<U extends RowRecord = any>(other: ConcatItem | ConcatItem[], options?: HorizontalConcatOptions): DataFrame<U>;
361
+ /**
362
+ * Inserts a new column at a specific ordinal index position.
363
+ * @param index Target column index position.
364
+ * @param name Name of the inserted column.
365
+ * @param expr Value expression or column definition.
366
+ * @returns DataFrame
367
+ * @example
368
+ * >>> const df = $df.data({ a: [1], c: [3] })
369
+ * >>> df
370
+ * shape: (1, 2)
371
+ * ┌───┬───┐
372
+ * │ a │ c │
373
+ * ├───┼───┤
374
+ * │ 1 │ 3 │
375
+ * └───┴───┘
376
+ * >>> df.insert_column(1, "b", 2)
377
+ * shape: (1, 3)
378
+ * ┌───┬───┬───┐
379
+ * │ a │ b │ c │
380
+ * ├───┼───┼───┤
381
+ * │ 1 │ 2 │ 3 │
382
+ * └───┴───┴───┘
383
+ */
25
384
  insert_column(index: number, name: string, expr: IntoExpr): DataFrame<any>;
385
+ /**
386
+ * Retrieves a single scalar cell value by row and column position or name.
387
+ * @param row Row index position.
388
+ * @param column Column index or column name string.
389
+ * @returns Cell scalar value.
390
+ * @throws {DataFrameError} If shape is not (1, 1) when called without arguments.
391
+ * @throws {ShapeError} If row or column index is out of bounds.
392
+ * @example
393
+ * >>> const df = $df.data({ val: [42] })
394
+ * >>> df
395
+ * shape: (1, 1)
396
+ * ┌─────┐
397
+ * │ val │
398
+ * ├─────┤
399
+ * │ 42 │
400
+ * └─────┘
401
+ * >>> df.item(0, "val")
402
+ * 42
403
+ */
26
404
  item(row?: number, column?: number | string): any;
405
+ /**
406
+ * Yields a generator iterating over raw column arrays.
407
+ * @returns Generator of ColumnData arrays.
408
+ * @example
409
+ * >>> const df = $df.data({ a: [1, 2], b: [3, 4] })
410
+ * >>> df
411
+ * shape: (2, 2)
412
+ * ┌───┬───┐
413
+ * │ a │ b │
414
+ * ├───┼───┤
415
+ * │ 1 │ 3 │
416
+ * │ 2 │ 4 │
417
+ * └───┴───┘
418
+ * >>> for (const col of df.iter_columns()) { console.log(col); }
419
+ * Float64Array([1, 2])
420
+ * Float64Array([3, 4])
421
+ */
27
422
  iter_columns(): Generator<ColumnData>;
423
+ /**
424
+ * Yields a generator iterating over rows as tuples or named objects.
425
+ * @param [config] Iteration format configuration.
426
+ * @param [config.named] When `true`, yields row objects with column keys (`{ col: val }`). When `false` (default), yields positional arrays (`[val1, val2]`).
427
+ * @returns Generator of rows.
428
+ * @example
429
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
430
+ * >>> df
431
+ * shape: (2, 2)
432
+ * ┌───┬───┐
433
+ * │ a │ b │
434
+ * ├───┼───┤
435
+ * │ 1 │ x │
436
+ * │ 2 │ y │
437
+ * └───┴───┘
438
+ * >>> for (const row of df.iter_rows({ named: true })) { console.log(row); }
439
+ * { a: 1, b: "x" }
440
+ * { a: 2, b: "y" }
441
+ */
28
442
  iter_rows({ named }?: {
29
443
  named?: boolean;
30
444
  }): Generator<any[] | Record<string, any>>;
445
+ /**
446
+ * Joins two DataFrames on key columns using inner, left, right, or outer join strategy.
447
+ * @param config Join configuration object.
448
+ * @param config.other Right DataFrame to join with left DataFrame.
449
+ * @param config.on Join key column name or array of key column names.
450
+ * @param [config.how] Join strategy (`"inner"`, `"left"`, `"right"`, or `"outer"`). Default `"inner"`.
451
+ * @param [config.suffixes] Custom column name suffix tuple `[leftSuffix, rightSuffix]` for overlapping non-key columns (default `["", "_right"]`).
452
+ * @returns DataFrame
453
+ * @example
454
+ * >>> const df1 = $df.data({ id: [1, 2], val: ["a", "b"] })
455
+ * >>> df1
456
+ * shape: (2, 2)
457
+ * ┌────┬─────┐
458
+ * │ id │ val │
459
+ * ├────┼─────┤
460
+ * │ 1 │ a │
461
+ * │ 2 │ b │
462
+ * └────┴─────┘
463
+ * >>> const df2 = $df.data({ id: [1, 2], num: [100, 200] })
464
+ * >>> df1.join({ other: df2, on: "id" })
465
+ * shape: (2, 3)
466
+ * ┌────┬─────┬─────┐
467
+ * │ id │ val │ num │
468
+ * ├────┼─────┼─────┤
469
+ * │ 1 │ a │ 100 │
470
+ * │ 2 │ b │ 200 │
471
+ * └────┴─────┴─────┘
472
+ */
31
473
  join<U extends RowRecord = any, R extends RowRecord = any>(config: JoinOptions<T, U>): DataFrame<R>;
474
+ /**
475
+ * Limits the output to N rows starting from offset.
476
+ * @param n Maximum number of rows to take.
477
+ * @param [options] Offset and slice direction options.
478
+ * @param [options.offset] Number of rows to skip before taking `n` rows (default 0).
479
+ * @param [options.from] Slice direction starting point (`"start"` or `"end"`). Default `"start"`.
480
+ * @returns DataFrame
481
+ * @example
482
+ * >>> const df = $df.data({ a: [10, 20, 30, 40] })
483
+ * >>> df
484
+ * shape: (4, 1)
485
+ * ┌────┐
486
+ * │ a │
487
+ * ├────┤
488
+ * │ 10 │
489
+ * │ 20 │
490
+ * │ 30 │
491
+ * │ 40 │
492
+ * └────┘
493
+ * >>> df.limit(2, { offset: 1 })
494
+ * shape: (2, 1)
495
+ * ┌────┐
496
+ * │ a │
497
+ * ├────┤
498
+ * │ 20 │
499
+ * │ 30 │
500
+ * └────┘
501
+ */
32
502
  limit(n: number, { offset, from }?: LimitOptions): DataFrame<T>;
503
+ /**
504
+ * Pivots columns from long format to a wide datagrid structure.
505
+ * @param config Pivot table configuration options.
506
+ * @param {string | string[]} config.index Key column(s) to use as new DataFrame rows.
507
+ * @param {string} config.columns Column whose distinct values become new wide column headers.
508
+ * @param {string} config.values Column whose cell values populate the pivoted grid cells.
509
+ * @param {AggFn | string} [config.agg] Aggregation function to apply when multiple values exist for a cell.
510
+ * @returns DataFrame
511
+ * @example
512
+ * >>> const df = $df.data({
513
+ * ... year: [2020, 2020, 2021, 2021],
514
+ * ... month: ["Jan", "Feb", "Jan", "Feb"],
515
+ * ... revenue: [100, 150, 120, 180]
516
+ * ... })
517
+ * >>> df
518
+ * shape: (4, 3)
519
+ * ┌──────┬───────┬─────────┐
520
+ * │ year │ month │ revenue │
521
+ * ├──────┼───────┼─────────┤
522
+ * │ 2020 │ Jan │ 100 │
523
+ * │ 2020 │ Feb │ 150 │
524
+ * │ 2021 │ Jan │ 120 │
525
+ * │ 2021 │ Feb │ 180 │
526
+ * └──────┴───────┴─────────┘
527
+ * >>> df.pivot({ index: "year", columns: "month", values: "revenue" })
528
+ * shape: (2, 3)
529
+ * ┌──────┬─────┬─────┐
530
+ * │ year │ Jan │ Feb │
531
+ * ├──────┼─────┼─────┤
532
+ * │ 2020 │ 100 │ 150 │
533
+ * │ 2021 │ 120 │ 180 │
534
+ * └──────┴─────┴─────┘
535
+ */
33
536
  pivot<U extends RowRecord = any>(config: PivotOptions<T>): DataFrame<U>;
537
+ /**
538
+ * Renames columns based on a key-value mapping dictionary.
539
+ * @param mapping Dictionary mapping old column names to new names.
540
+ * @returns DataFrame
541
+ * @example
542
+ * >>> const df = $df.data({ old_name: [1] })
543
+ * >>> df
544
+ * shape: (1, 1)
545
+ * ┌──────────┐
546
+ * │ old_name │
547
+ * ├──────────┤
548
+ * │ 1 │
549
+ * └──────────┘
550
+ * >>> df.rename({ old_name: "new_name" })
551
+ * shape: (1, 1)
552
+ * ┌──────────┐
553
+ * │ new_name │
554
+ * ├──────────┤
555
+ * │ 1 │
556
+ * └──────────┘
557
+ */
34
558
  rename(mapping?: Partial<Record<keyof T, string>>): DataFrame<any>;
559
+ /**
560
+ * Reverses the row ordering of the DataFrame.
561
+ * @returns DataFrame
562
+ * @example
563
+ * >>> const df = $df.data({ a: [1, 2, 3] })
564
+ * >>> df
565
+ * shape: (3, 1)
566
+ * ┌───┐
567
+ * │ a │
568
+ * ├───┤
569
+ * │ 1 │
570
+ * │ 2 │
571
+ * │ 3 │
572
+ * └───┘
573
+ * >>> df.reverse()
574
+ * shape: (3, 1)
575
+ * ┌───┐
576
+ * │ a │
577
+ * ├───┤
578
+ * │ 3 │
579
+ * │ 2 │
580
+ * │ 1 │
581
+ * └───┘
582
+ */
35
583
  reverse(): DataFrame<T>;
584
+ /**
585
+ * Gets current DataFrameSchema dictionary mapping column names to DataType.
586
+ * @returns DataFrameSchema mapping.
587
+ * @example
588
+ * >>> const df = $df.data({ a: [1], b: ["text"] })
589
+ * >>> df
590
+ * shape: (1, 2)
591
+ * ┌───┬──────┐
592
+ * │ a │ b │
593
+ * ├───┼──────┤
594
+ * │ 1 │ text │
595
+ * └───┴──────┘
596
+ * >>> df.schema
597
+ * { a: Float64, b: Utf8 }
598
+ */
36
599
  get schema(): DataFrameSchema;
600
+ /**
601
+ * Selects specific columns or evaluates column expressions.
602
+ * @param args Column names, column expressions, or object maps to evaluate.
603
+ * @returns DataFrame
604
+ * @example
605
+ * >>> const df = $df.data({ a: [1, 2], b: [10, 20] })
606
+ * >>> df
607
+ * shape: (2, 2)
608
+ * ┌───┬────┐
609
+ * │ a │ b │
610
+ * ├───┼────┤
611
+ * │ 1 │ 10 │
612
+ * │ 2 │ 20 │
613
+ * └───┴────┘
614
+ * >>> df.select("a", $df.col("b").add(100).alias("b_plus"))
615
+ * shape: (2, 2)
616
+ * ┌───┬────────┐
617
+ * │ a │ b_plus │
618
+ * ├───┼────────┤
619
+ * │ 1 │ 110 │
620
+ * │ 2 │ 120 │
621
+ * └───┴────────┘
622
+ */
37
623
  select<U extends RowRecord = any>(...args: (string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]): DataFrame<U>;
624
+ /**
625
+ * Gets DataFrame dimensions as [height, width] tuple.
626
+ * @returns Tuple [height, width].
627
+ * @example
628
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
629
+ * >>> df
630
+ * shape: (2, 2)
631
+ * ┌───┬───┐
632
+ * │ a │ b │
633
+ * ├───┼───┤
634
+ * │ 1 │ x │
635
+ * │ 2 │ y │
636
+ * └───┴───┘
637
+ * >>> df.shape
638
+ * [2, 2]
639
+ */
38
640
  get shape(): [number, number];
641
+ /**
642
+ * Slices a subset range of rows between start and end index.
643
+ * @param start Starting row index.
644
+ * @param end Optional ending row index (exclusive).
645
+ * @returns DataFrame
646
+ * @example
647
+ * >>> const df = $df.data({ a: [10, 20, 30, 40] })
648
+ * >>> df
649
+ * shape: (4, 1)
650
+ * ┌────┐
651
+ * │ a │
652
+ * ├────┤
653
+ * │ 10 │
654
+ * │ 20 │
655
+ * │ 30 │
656
+ * │ 40 │
657
+ * └────┘
658
+ * >>> df.slice(1, 3)
659
+ * shape: (2, 1)
660
+ * ┌────┐
661
+ * │ a │
662
+ * ├────┤
663
+ * │ 20 │
664
+ * │ 30 │
665
+ * └────┘
666
+ */
39
667
  slice(start: number, end?: number): DataFrame<T>;
668
+ /**
669
+ * Sorts DataFrame rows by one or more column expressions or custom sorters.
670
+ * @param config Sort configuration options.
671
+ * @param config.by Column name(s) or expression(s) to sort by.
672
+ * @param [config.descending] Sort order boolean or array of booleans per key (default `false`).
673
+ * @param [config.nullsLast] When `true` (default), places nulls at the end of sorted output.
674
+ * @param [config.custom] Optional dictionary mapping column names to custom comparator functions.
675
+ * @returns DataFrame
676
+ * @example
677
+ * >>> const df = $df.data({ val: [3, 1, 2] })
678
+ * >>> df
679
+ * shape: (3, 1)
680
+ * ┌─────┐
681
+ * │ val │
682
+ * ├─────┤
683
+ * │ 3 │
684
+ * │ 1 │
685
+ * │ 2 │
686
+ * └─────┘
687
+ * >>> df.sort({ by: "val" })
688
+ * shape: (3, 1)
689
+ * ┌─────┐
690
+ * │ val │
691
+ * ├─────┤
692
+ * │ 1 │
693
+ * │ 2 │
694
+ * │ 3 │
695
+ * └─────┘
696
+ */
40
697
  sort(config?: SortOptions<T>): DataFrame<T>;
698
+ /**
699
+ * Returns the last N rows as a new DataFrame.
700
+ * @param n Number of trailing rows to take (default 10).
701
+ * @returns DataFrame
702
+ * @example
703
+ * >>> const df = $df.data({ a: [1, 2, 3, 4] })
704
+ * >>> df
705
+ * shape: (4, 1)
706
+ * ┌───┐
707
+ * │ a │
708
+ * ├───┤
709
+ * │ 1 │
710
+ * │ 2 │
711
+ * │ 3 │
712
+ * │ 4 │
713
+ * └───┘
714
+ * >>> df.tail(2)
715
+ * shape: (2, 1)
716
+ * ┌───┐
717
+ * │ a │
718
+ * ├───┤
719
+ * │ 3 │
720
+ * │ 4 │
721
+ * └───┘
722
+ */
41
723
  tail(n?: number): DataFrame<T>;
724
+ /**
725
+ * Converts columns into a JavaScript dictionary mapping column keys to raw arrays.
726
+ * @returns Column dictionary map.
727
+ * @example
728
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
729
+ * >>> df
730
+ * shape: (2, 2)
731
+ * ┌───┬───┐
732
+ * │ a │ b │
733
+ * ├───┼───┤
734
+ * │ 1 │ x │
735
+ * │ 2 │ y │
736
+ * └───┴───┘
737
+ * >>> df.to_dict()
738
+ * { a: Float64Array([1, 2]), b: ["x", "y"] }
739
+ */
42
740
  to_dict(): DataFrameColumns<T>;
741
+ /**
742
+ * Converts rows into an array of JavaScript objects.
743
+ * @returns Array of row record objects.
744
+ * @example
745
+ * >>> const df = $df.data({ a: [1], b: ["x"] })
746
+ * >>> df
747
+ * shape: (1, 2)
748
+ * ┌───┬───┐
749
+ * │ a │ b │
750
+ * ├───┼───┤
751
+ * │ 1 │ x │
752
+ * └───┴───┘
753
+ * >>> df.to_dicts()
754
+ * [{ a: 1, b: "x" }]
755
+ */
43
756
  to_dicts(): T[];
44
- to_list<K extends keyof T>(nameOrExpr: K | IExpr): any[];
757
+ /**
758
+ * Evaluates a column expression or retrieves column values as a raw JavaScript array.
759
+ * @param nameOrExpr Target column name or column expression.
760
+ * @returns Array of column scalar values.
761
+ * @example
762
+ * >>> const df = $df.data({ a: [10, 20] })
763
+ * >>> df
764
+ * shape: (2, 1)
765
+ * ┌────┐
766
+ * │ a │
767
+ * ├────┤
768
+ * │ 10 │
769
+ * │ 20 │
770
+ * └────┘
771
+ * >>> df.to_array("a")
772
+ * [10, 20]
773
+ */
774
+ to_array<K extends keyof T>(nameOrExpr: K | IExpr): any[];
775
+ /**
776
+ * Transposes rows into columns and columns into rows.
777
+ * @param [options] Transpose layout options.
778
+ * @param [options.include_header] When `true`, includes original column names as a new header column (default `false`).
779
+ * @param [options.header_name] Name of the header column when `include_header` is `true` (default `"column"`).
780
+ * @param [options.column_names] Column name or iterable of strings to use as transposed column headers.
781
+ * @returns DataFrame
782
+ * @example
783
+ * >>> const df = $df.data({ metric: ["sales", "clicks"], q1: [100, 500], q2: [120, 600] })
784
+ * >>> df
785
+ * shape: (2, 3)
786
+ * ┌────────┬─────┬─────┐
787
+ * │ metric │ q1 │ q2 │
788
+ * ├────────┼─────┼─────┤
789
+ * │ sales │ 100 │ 120 │
790
+ * │ clicks │ 500 │ 600 │
791
+ * └────────┴─────┴─────┘
792
+ * >>> df.transpose({ include_header: true, header_name: "metric" })
793
+ * shape: (2, 3)
794
+ * ┌────────┬──────────┬──────────┐
795
+ * │ metric │ column_0 │ column_1 │
796
+ * ├────────┼──────────┼──────────┤
797
+ * │ q1 │ 100 │ 500 │
798
+ * │ q2 │ 120 │ 600 │
799
+ * └────────┴──────────┴──────────┘
800
+ */
45
801
  transpose({ include_header: includeHeader, header_name: headerName, column_names: colNamesOpt }?: TransposeOptions): DataFrame<any>;
802
+ /**
803
+ * Filters distinct unique rows matching target key columns.
804
+ * @param columns Target column or array of column names to evaluate uniqueness.
805
+ * @returns DataFrame
806
+ * @example
807
+ * >>> const df = $df.data({ a: [1, 2, 2], b: ["x", "y", "y"] })
808
+ * >>> df
809
+ * shape: (3, 2)
810
+ * ┌───┬───┐
811
+ * │ a │ b │
812
+ * ├───┼───┤
813
+ * │ 1 │ x │
814
+ * │ 2 │ y │
815
+ * │ 2 │ y │
816
+ * └───┴───┘
817
+ * >>> df.unique()
818
+ * shape: (2, 2)
819
+ * ┌───┬───┐
820
+ * │ a │ b │
821
+ * ├───┼───┤
822
+ * │ 1 │ x │
823
+ * │ 2 │ y │
824
+ * └───┴───┘
825
+ */
46
826
  unique<K extends keyof T>(columns?: K | K[]): DataFrame<T>;
827
+ /**
828
+ * Unpivots a wide DataFrame into a long format structure.
829
+ * @param config Unpivot configuration options.
830
+ * @param config.idVars Key column(s) to retain as identifier variables.
831
+ * @param config.valueVars Column(s) to unpivot into variable-value pairs.
832
+ * @param [config.varName] Name for the new variable column holding old column headers (default `"variable"`).
833
+ * @param [config.valueName] Name for the new value column holding cell values (default `"value"`).
834
+ * @returns DataFrame
835
+ * @example
836
+ * >>> const df = $df.data({ year: [2020], Jan: [100], Feb: [150] })
837
+ * >>> df
838
+ * shape: (1, 3)
839
+ * ┌──────┬─────┬─────┐
840
+ * │ year │ Jan │ Feb │
841
+ * ├──────┼─────┼─────┤
842
+ * │ 2020 │ 100 │ 150 │
843
+ * └──────┴─────┴─────┘
844
+ * >>> df.unpivot({ idVars: "year", valueVars: ["Jan", "Feb"], varName: "month", valueName: "revenue" })
845
+ * shape: (2, 3)
846
+ * ┌──────┬───────┬─────────┐
847
+ * │ year │ month │ revenue │
848
+ * ├──────┼───────┼─────────┤
849
+ * │ 2020 │ Jan │ 100 │
850
+ * │ 2020 │ Feb │ 150 │
851
+ * └──────┴───────┴─────────┘
852
+ */
47
853
  unpivot<U extends RowRecord = any>(config: UnpivotOptions<T>): DataFrame<U>;
854
+ /**
855
+ * Concatenates DataFrames vertically. Alias for concat({ how: "vertical" }).
856
+ * @param other Single DataFrame or array of DataFrames to append vertically.
857
+ * @returns DataFrame
858
+ * @example
859
+ * >>> const df1 = $df.data({ a: [1] })
860
+ * >>> df1
861
+ * shape: (1, 1)
862
+ * ┌───┐
863
+ * │ a │
864
+ * ├───┤
865
+ * │ 1 │
866
+ * └───┘
867
+ * >>> const df2 = $df.data({ a: [2] })
868
+ * >>> df1.vstack(df2)
869
+ * shape: (2, 1)
870
+ * ┌───┐
871
+ * │ a │
872
+ * ├───┤
873
+ * │ 1 │
874
+ * │ 2 │
875
+ * └───┘
876
+ */
48
877
  vstack<U extends RowRecord = any>(other: ConcatItem | ConcatItem[]): DataFrame<U>;
878
+ /**
879
+ * Gets width (total column count) of the DataFrame.
880
+ * @returns Number of columns.
881
+ * @example
882
+ * >>> const df = $df.data({ a: [1], b: [2] })
883
+ * >>> df
884
+ * shape: (1, 2)
885
+ * ┌───┬───┐
886
+ * │ a │ b │
887
+ * ├───┼───┤
888
+ * │ 1 │ 2 │
889
+ * └───┴───┘
890
+ * >>> df.width
891
+ * 2
892
+ */
49
893
  get width(): number;
50
894
  private _normalizeArgs;
895
+ /**
896
+ * Adds new columns or updates existing ones using column expressions.
897
+ * @param args Expressions or field objects defining column calculations.
898
+ * @returns DataFrame
899
+ * @example
900
+ * >>> const df = $df.data({ a: [1, 2] })
901
+ * >>> df
902
+ * shape: (2, 1)
903
+ * ┌───┐
904
+ * │ a │
905
+ * ├───┤
906
+ * │ 1 │
907
+ * │ 2 │
908
+ * └───┘
909
+ * >>> df.with_columns($df.col("a").add(10).alias("b"))
910
+ * shape: (2, 2)
911
+ * ┌───┬────┐
912
+ * │ a │ b │
913
+ * ├───┼────┤
914
+ * │ 1 │ 11 │
915
+ * │ 2 │ 12 │
916
+ * └───┴────┘
917
+ */
51
918
  with_columns(...args: (string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]): DataFrame<any>;
919
+ /**
920
+ * Appends an incremental index column.
921
+ * @param name Name of index column (default "index").
922
+ * @param offset Starting numeric index offset (default 0).
923
+ * @returns DataFrame
924
+ * @example
925
+ * >>> const df = $df.data({ val: ["a", "b"] })
926
+ * >>> df
927
+ * shape: (2, 1)
928
+ * ┌─────┐
929
+ * │ val │
930
+ * ├─────┤
931
+ * │ a │
932
+ * │ b │
933
+ * └─────┘
934
+ * >>> df.with_row_index("idx")
935
+ * shape: (2, 2)
936
+ * ┌─────┬─────┐
937
+ * │ idx │ val │
938
+ * ├─────┼─────┤
939
+ * │ 0 │ a │
940
+ * │ 1 │ b │
941
+ * └─────┴─────┘
942
+ */
52
943
  with_row_index(name?: string, offset?: number): DataFrame<any>;
944
+ /**
945
+ * Writes DataFrame rows to JSON format string or file/stream target.
946
+ * @param [file] Target file path or writable stream target (optional).
947
+ * @param [options] JSON formatting and replacer options.
948
+ * @param [options.format] JSON output format structure (`"json"` or `"ndjson"`). Default `"json"`.
949
+ * @param [options.replacerOptions] Serialization options including custom `replacer` function or replacer array.
950
+ * @returns JSON string representation.
951
+ * @example
952
+ * >>> const df = $df.data({ a: [1], b: ["x"] })
953
+ * >>> df
954
+ * shape: (1, 2)
955
+ * ┌───┬───┐
956
+ * │ a │ b │
957
+ * ├───┼───┤
958
+ * │ 1 │ x │
959
+ * └───┴───┘
960
+ * >>> df.write_json()
961
+ * '[{"a":1,"b":"x"}]'
962
+ */
53
963
  write_json(file?: string | {
54
964
  write: (str: string) => void;
55
965
  }, { format, replacerOptions }?: WriteJSONOptions): string;
966
+ /**
967
+ * Writes DataFrame to CSV format string or file/stream target.
968
+ * @param [file] Target file path or writable stream target (optional).
969
+ * @param [options] CSV formatting options.
970
+ * @param [options.delimiter] Column delimiter character (default `","`).
971
+ * @param [options.header] When `true` (default), includes column header row.
972
+ * @param [options.quoteChar] Character used to enclose fields containing special characters (default `'"'`).
973
+ * @returns CSV string output.
974
+ * @example
975
+ * >>> const df = $df.data({ a: [1], b: ["x"] })
976
+ * >>> df
977
+ * shape: (1, 2)
978
+ * ┌───┬───┐
979
+ * │ a │ b │
980
+ * ├───┼───┤
981
+ * │ 1 │ x │
982
+ * └───┴───┘
983
+ * >>> df.write_csv()
984
+ * "a,b\n1,x"
985
+ */
56
986
  write_csv(file?: string | {
57
987
  write: (str: string) => void;
58
988
  }, options?: WriteCSVOptions): string;