deepbox 0.1.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 (173) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +344 -0
  3. package/dist/CSRMatrix-CwGwQRea.d.cts +219 -0
  4. package/dist/CSRMatrix-KzNt6QpS.d.ts +219 -0
  5. package/dist/Tensor-BQLk1ltW.d.cts +147 -0
  6. package/dist/Tensor-g8mUClel.d.ts +147 -0
  7. package/dist/chunk-4S73VUBD.js +677 -0
  8. package/dist/chunk-4S73VUBD.js.map +1 -0
  9. package/dist/chunk-5R4S63PF.js +2925 -0
  10. package/dist/chunk-5R4S63PF.js.map +1 -0
  11. package/dist/chunk-6AE5FKKQ.cjs +9264 -0
  12. package/dist/chunk-6AE5FKKQ.cjs.map +1 -0
  13. package/dist/chunk-AD436M45.js +3854 -0
  14. package/dist/chunk-AD436M45.js.map +1 -0
  15. package/dist/chunk-ALS7ETWZ.cjs +4263 -0
  16. package/dist/chunk-ALS7ETWZ.cjs.map +1 -0
  17. package/dist/chunk-AU7XHGKJ.js +2092 -0
  18. package/dist/chunk-AU7XHGKJ.js.map +1 -0
  19. package/dist/chunk-B5TNKUEY.js +1481 -0
  20. package/dist/chunk-B5TNKUEY.js.map +1 -0
  21. package/dist/chunk-BCR7G3A6.js +9136 -0
  22. package/dist/chunk-BCR7G3A6.js.map +1 -0
  23. package/dist/chunk-C4PKXY74.cjs +1917 -0
  24. package/dist/chunk-C4PKXY74.cjs.map +1 -0
  25. package/dist/chunk-DWZY6PIP.cjs +6400 -0
  26. package/dist/chunk-DWZY6PIP.cjs.map +1 -0
  27. package/dist/chunk-E3EU5FZO.cjs +2113 -0
  28. package/dist/chunk-E3EU5FZO.cjs.map +1 -0
  29. package/dist/chunk-F3JWBINJ.js +1054 -0
  30. package/dist/chunk-F3JWBINJ.js.map +1 -0
  31. package/dist/chunk-FJYLIGJX.js +1940 -0
  32. package/dist/chunk-FJYLIGJX.js.map +1 -0
  33. package/dist/chunk-JSCDE774.cjs +729 -0
  34. package/dist/chunk-JSCDE774.cjs.map +1 -0
  35. package/dist/chunk-LWECRCW2.cjs +2412 -0
  36. package/dist/chunk-LWECRCW2.cjs.map +1 -0
  37. package/dist/chunk-MLBMYKCG.js +6379 -0
  38. package/dist/chunk-MLBMYKCG.js.map +1 -0
  39. package/dist/chunk-OX6QXFMV.cjs +3874 -0
  40. package/dist/chunk-OX6QXFMV.cjs.map +1 -0
  41. package/dist/chunk-PHV2DKRS.cjs +1072 -0
  42. package/dist/chunk-PHV2DKRS.cjs.map +1 -0
  43. package/dist/chunk-PL7TAYKI.js +4056 -0
  44. package/dist/chunk-PL7TAYKI.js.map +1 -0
  45. package/dist/chunk-PR647I7R.js +1898 -0
  46. package/dist/chunk-PR647I7R.js.map +1 -0
  47. package/dist/chunk-QERHVCHC.cjs +2960 -0
  48. package/dist/chunk-QERHVCHC.cjs.map +1 -0
  49. package/dist/chunk-XEG44RF6.cjs +1514 -0
  50. package/dist/chunk-XEG44RF6.cjs.map +1 -0
  51. package/dist/chunk-XMWVME2W.js +2377 -0
  52. package/dist/chunk-XMWVME2W.js.map +1 -0
  53. package/dist/chunk-ZB75FESB.cjs +1979 -0
  54. package/dist/chunk-ZB75FESB.cjs.map +1 -0
  55. package/dist/chunk-ZLW62TJG.cjs +4061 -0
  56. package/dist/chunk-ZLW62TJG.cjs.map +1 -0
  57. package/dist/chunk-ZXKBDFP3.js +4235 -0
  58. package/dist/chunk-ZXKBDFP3.js.map +1 -0
  59. package/dist/core/index.cjs +204 -0
  60. package/dist/core/index.cjs.map +1 -0
  61. package/dist/core/index.d.cts +2 -0
  62. package/dist/core/index.d.ts +2 -0
  63. package/dist/core/index.js +3 -0
  64. package/dist/core/index.js.map +1 -0
  65. package/dist/dataframe/index.cjs +22 -0
  66. package/dist/dataframe/index.cjs.map +1 -0
  67. package/dist/dataframe/index.d.cts +3 -0
  68. package/dist/dataframe/index.d.ts +3 -0
  69. package/dist/dataframe/index.js +5 -0
  70. package/dist/dataframe/index.js.map +1 -0
  71. package/dist/datasets/index.cjs +134 -0
  72. package/dist/datasets/index.cjs.map +1 -0
  73. package/dist/datasets/index.d.cts +3 -0
  74. package/dist/datasets/index.d.ts +3 -0
  75. package/dist/datasets/index.js +5 -0
  76. package/dist/datasets/index.js.map +1 -0
  77. package/dist/index-74AB8Cyh.d.cts +1126 -0
  78. package/dist/index-9oQx1HgV.d.cts +1180 -0
  79. package/dist/index-BJY2SI4i.d.ts +483 -0
  80. package/dist/index-BWGhrDlr.d.ts +733 -0
  81. package/dist/index-B_DK4FKY.d.cts +242 -0
  82. package/dist/index-BbA2Gxfl.d.ts +456 -0
  83. package/dist/index-BgHYAoSS.d.cts +837 -0
  84. package/dist/index-BndMbqsM.d.ts +1439 -0
  85. package/dist/index-C1mfVYoo.d.ts +2517 -0
  86. package/dist/index-CCvlwAmL.d.cts +809 -0
  87. package/dist/index-CDw5CnOU.d.ts +785 -0
  88. package/dist/index-Cn3SdB0O.d.ts +1126 -0
  89. package/dist/index-CrqLlS-a.d.ts +776 -0
  90. package/dist/index-D61yaSMY.d.cts +483 -0
  91. package/dist/index-D9Loo1_A.d.cts +2517 -0
  92. package/dist/index-DIT_OO9C.d.cts +785 -0
  93. package/dist/index-DIp_RrRt.d.ts +242 -0
  94. package/dist/index-DbultU6X.d.cts +1427 -0
  95. package/dist/index-DmEg_LCm.d.cts +776 -0
  96. package/dist/index-DoPWVxPo.d.cts +1439 -0
  97. package/dist/index-DuCxd-8d.d.ts +837 -0
  98. package/dist/index-Dx42TZaY.d.ts +809 -0
  99. package/dist/index-DyZ4QQf5.d.cts +456 -0
  100. package/dist/index-GFAVyOWO.d.ts +1427 -0
  101. package/dist/index-WHQLn0e8.d.cts +733 -0
  102. package/dist/index-ZtI1Iy4L.d.ts +1180 -0
  103. package/dist/index-eJgeni9c.d.cts +1911 -0
  104. package/dist/index-tk4lSYod.d.ts +1911 -0
  105. package/dist/index.cjs +72 -0
  106. package/dist/index.cjs.map +1 -0
  107. package/dist/index.d.cts +17 -0
  108. package/dist/index.d.ts +17 -0
  109. package/dist/index.js +15 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/linalg/index.cjs +86 -0
  112. package/dist/linalg/index.cjs.map +1 -0
  113. package/dist/linalg/index.d.cts +3 -0
  114. package/dist/linalg/index.d.ts +3 -0
  115. package/dist/linalg/index.js +5 -0
  116. package/dist/linalg/index.js.map +1 -0
  117. package/dist/metrics/index.cjs +158 -0
  118. package/dist/metrics/index.cjs.map +1 -0
  119. package/dist/metrics/index.d.cts +3 -0
  120. package/dist/metrics/index.d.ts +3 -0
  121. package/dist/metrics/index.js +5 -0
  122. package/dist/metrics/index.js.map +1 -0
  123. package/dist/ml/index.cjs +87 -0
  124. package/dist/ml/index.cjs.map +1 -0
  125. package/dist/ml/index.d.cts +3 -0
  126. package/dist/ml/index.d.ts +3 -0
  127. package/dist/ml/index.js +6 -0
  128. package/dist/ml/index.js.map +1 -0
  129. package/dist/ndarray/index.cjs +501 -0
  130. package/dist/ndarray/index.cjs.map +1 -0
  131. package/dist/ndarray/index.d.cts +5 -0
  132. package/dist/ndarray/index.d.ts +5 -0
  133. package/dist/ndarray/index.js +4 -0
  134. package/dist/ndarray/index.js.map +1 -0
  135. package/dist/nn/index.cjs +142 -0
  136. package/dist/nn/index.cjs.map +1 -0
  137. package/dist/nn/index.d.cts +6 -0
  138. package/dist/nn/index.d.ts +6 -0
  139. package/dist/nn/index.js +5 -0
  140. package/dist/nn/index.js.map +1 -0
  141. package/dist/optim/index.cjs +77 -0
  142. package/dist/optim/index.cjs.map +1 -0
  143. package/dist/optim/index.d.cts +4 -0
  144. package/dist/optim/index.d.ts +4 -0
  145. package/dist/optim/index.js +4 -0
  146. package/dist/optim/index.js.map +1 -0
  147. package/dist/plot/index.cjs +114 -0
  148. package/dist/plot/index.cjs.map +1 -0
  149. package/dist/plot/index.d.cts +6 -0
  150. package/dist/plot/index.d.ts +6 -0
  151. package/dist/plot/index.js +5 -0
  152. package/dist/plot/index.js.map +1 -0
  153. package/dist/preprocess/index.cjs +82 -0
  154. package/dist/preprocess/index.cjs.map +1 -0
  155. package/dist/preprocess/index.d.cts +4 -0
  156. package/dist/preprocess/index.d.ts +4 -0
  157. package/dist/preprocess/index.js +5 -0
  158. package/dist/preprocess/index.js.map +1 -0
  159. package/dist/random/index.cjs +74 -0
  160. package/dist/random/index.cjs.map +1 -0
  161. package/dist/random/index.d.cts +3 -0
  162. package/dist/random/index.d.ts +3 -0
  163. package/dist/random/index.js +5 -0
  164. package/dist/random/index.js.map +1 -0
  165. package/dist/stats/index.cjs +142 -0
  166. package/dist/stats/index.cjs.map +1 -0
  167. package/dist/stats/index.d.cts +3 -0
  168. package/dist/stats/index.d.ts +3 -0
  169. package/dist/stats/index.js +5 -0
  170. package/dist/stats/index.js.map +1 -0
  171. package/dist/tensor-B96jjJLQ.d.cts +205 -0
  172. package/dist/tensor-B96jjJLQ.d.ts +205 -0
  173. package/package.json +226 -0
@@ -0,0 +1,1427 @@
1
+ import { A as Axis } from './tensor-B96jjJLQ.cjs';
2
+ import { T as Tensor } from './Tensor-BQLk1ltW.cjs';
3
+
4
+ /**
5
+ * Data structure for DataFrame initialization.
6
+ *
7
+ * Maps column names to arrays of values. All arrays must have the same length.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const data: DataFrameData = {
12
+ * name: ['Alice', 'Bob', 'Charlie'],
13
+ * age: [25, 30, 35],
14
+ * score: [85.5, 92.0, 78.5]
15
+ * };
16
+ * ```
17
+ */
18
+ type DataFrameData = Record<string, unknown[]>;
19
+ /**
20
+ * Configuration options for DataFrame construction.
21
+ *
22
+ * @property index - Custom row labels (defaults to 0, 1, 2, ...). Can be strings or numbers.
23
+ * @property columns - Custom column order (defaults to Object.keys order)
24
+ * @property copy - Whether to copy data on construction (default: true). Set to false for performance if data ownership can be transferred.
25
+ */
26
+ type DataFrameOptions = {
27
+ index?: (string | number)[];
28
+ columns?: string[];
29
+ copy?: boolean;
30
+ };
31
+ /**
32
+ * Configuration options for Series construction.
33
+ *
34
+ * @property name - Optional name for the Series
35
+ * @property index - Custom index labels (defaults to 0, 1, 2, ...). Can be strings or numbers.
36
+ * @property copy - Whether to copy data on construction (default: true). Set to false for performance if data ownership can be transferred.
37
+ */
38
+ type SeriesOptions = {
39
+ name?: string;
40
+ index?: (string | number)[];
41
+ copy?: boolean;
42
+ };
43
+ /**
44
+ * Supported aggregation functions for DataFrame groupby operations.
45
+ *
46
+ * - `sum`: Sum of values
47
+ * - `mean`: Arithmetic mean
48
+ * - `median`: Median value
49
+ * - `min`: Minimum value
50
+ * - `max`: Maximum value
51
+ * - `std`: Standard deviation
52
+ * - `var`: Variance
53
+ * - `count`: Count of non-null values
54
+ * - `first`: First value in group
55
+ * - `last`: Last value in group
56
+ */
57
+ type AggregateFunction = "sum" | "mean" | "median" | "min" | "max" | "std" | "var" | "count" | "first" | "last";
58
+
59
+ /**
60
+ * One-dimensional labeled array capable of holding any data type.
61
+ *
62
+ * A Series is like a column in a spreadsheet or database table. It combines:
63
+ * - An array of data values
64
+ * - An array of index labels (can be strings or numbers)
65
+ * - An optional name
66
+ *
67
+ * Similar to pandas Series in Python.
68
+ *
69
+ * @template T - The type of data stored in the Series
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * // Create a numeric series
74
+ * const s = new Series([1, 2, 3, 4], { name: 'numbers' });
75
+ *
76
+ * // Create a series with custom index
77
+ * const s2 = new Series(['a', 'b', 'c'], {
78
+ * index: ['row1', 'row2', 'row3'],
79
+ * name: 'letters'
80
+ * });
81
+ * ```
82
+ *
83
+ * @see {@link https://pandas.pydata.org/docs/reference/api/pandas.Series.html | Pandas Series}
84
+ */
85
+ declare class Series<T = unknown> {
86
+ private _data;
87
+ private _index;
88
+ private _indexPos;
89
+ private _name;
90
+ /**
91
+ * Creates a new Series instance.
92
+ *
93
+ * @param data - Array of values to store in the Series
94
+ * @param options - Configuration options
95
+ * @param options.index - Custom index labels (defaults to 0, 1, 2, ...)
96
+ * @param options.name - Optional name for the Series
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const s = new Series([10, 20, 30], {
101
+ * index: ['a', 'b', 'c'],
102
+ * name: 'values'
103
+ * });
104
+ * ```
105
+ */
106
+ constructor(data: T[], options?: SeriesOptions);
107
+ /**
108
+ * Get the underlying data array.
109
+ *
110
+ * @returns Read-only view of the data array
111
+ */
112
+ get data(): readonly T[];
113
+ /**
114
+ * Get the index labels.
115
+ *
116
+ * @returns Read-only view of the index array
117
+ */
118
+ get index(): readonly (string | number)[];
119
+ /**
120
+ * Get the Series name.
121
+ *
122
+ * @returns The name of this Series, or undefined if not set
123
+ */
124
+ get name(): string | undefined;
125
+ /**
126
+ * Get the number of elements in the Series.
127
+ *
128
+ * @returns Length of the Series
129
+ */
130
+ get length(): number;
131
+ /**
132
+ * Get a value by label.
133
+ *
134
+ * This method is an alias for `loc()`. It performs strict label-based lookup.
135
+ * For positional access, use `iloc()`.
136
+ *
137
+ * @param label - The index label to look up
138
+ * @returns The value at that label, or undefined if not found
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * const s = new Series([10, 20, 30], { index: ['a', 'b', 'c'] });
143
+ * s.get('a'); // 10
144
+ * s.get('z'); // undefined
145
+ * ```
146
+ */
147
+ get(label: number | string): T | undefined;
148
+ /**
149
+ * Access a value by label (label-based indexing).
150
+ *
151
+ * @param label - The index label to look up
152
+ * @returns The value at that label, or undefined if not found
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * const s = new Series([10, 20], { index: ['a', 'b'] });
157
+ * s.loc('a'); // 10
158
+ * ```
159
+ */
160
+ loc(label: string | number): T | undefined;
161
+ /**
162
+ * Access a value by integer position (position-based indexing).
163
+ *
164
+ * @param position - The integer position (0-based)
165
+ * @returns The value at that position, or undefined if out of bounds
166
+ * @throws {IndexError} If position is out of bounds
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * const s = new Series([10, 20, 30]);
171
+ * s.iloc(0); // 10
172
+ * s.iloc(2); // 30
173
+ * ```
174
+ */
175
+ iloc(position: number): T | undefined;
176
+ /**
177
+ * Return the first n elements.
178
+ *
179
+ * @param n - Number of elements to return (default: 5)
180
+ * @returns New Series with the first n elements
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * const s = new Series([1, 2, 3, 4, 5, 6]);
185
+ * s.head(3); // Series([1, 2, 3])
186
+ * ```
187
+ */
188
+ head(n?: number): Series<T>;
189
+ /**
190
+ * Return the last n elements.
191
+ *
192
+ * @param n - Number of elements to return (default: 5)
193
+ * @returns New Series with the last n elements
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * const s = new Series([1, 2, 3, 4, 5, 6]);
198
+ * s.tail(3); // Series([4, 5, 6])
199
+ * ```
200
+ */
201
+ tail(n?: number): Series<T>;
202
+ /**
203
+ * Filter Series by a boolean predicate function.
204
+ *
205
+ * Filters both data AND index to maintain alignment.
206
+ *
207
+ * @param predicate - Function that returns true for elements to keep
208
+ * @returns New Series with only elements that passed the predicate
209
+ *
210
+ * @example
211
+ * ```ts
212
+ * const s = new Series([1, 2, 3, 4, 5]);
213
+ * s.filter(x => x > 2); // Series([3, 4, 5])
214
+ * ```
215
+ */
216
+ filter(predicate: (value: T, index: number) => boolean): Series<T>;
217
+ /**
218
+ * Transform each element using a mapping function.
219
+ *
220
+ * @template U - The type of the transformed values
221
+ * @param fn - Function to apply to each element
222
+ * @returns New Series with transformed values
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * const s = new Series([1, 2, 3]);
227
+ * s.map(x => x * 2); // Series([2, 4, 6])
228
+ * ```
229
+ */
230
+ map<U>(fn: (value: T, index: number) => U): Series<U>;
231
+ /**
232
+ * Sort the Series values.
233
+ *
234
+ * Preserves index-value mapping by sorting `[value, index]` pairs.
235
+ *
236
+ * @param ascending - Sort in ascending order (default: true)
237
+ * @returns New sorted Series with index reordered to match
238
+ *
239
+ * @example
240
+ * ```ts
241
+ * const s = new Series([3, 1, 2], { index: ['a', 'b', 'c'] });
242
+ * s.sort(); // Series([1, 2, 3]) with index ['b', 'c', 'a']
243
+ * ```
244
+ */
245
+ sort(ascending?: boolean): Series<T>;
246
+ /**
247
+ * Get unique values in the Series.
248
+ *
249
+ * @returns Array of unique values (order preserved)
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * const s = new Series([1, 2, 2, 3, 1]);
254
+ * s.unique(); // [1, 2, 3]
255
+ * ```
256
+ */
257
+ unique(): T[];
258
+ /**
259
+ * Count occurrences of unique values.
260
+ *
261
+ * Returns a Series where index is the unique values and data is their counts.
262
+ *
263
+ * @returns Series where index is unique values and data is their counts
264
+ *
265
+ * @example
266
+ * ```ts
267
+ * const s = new Series(['a', 'b', 'a', 'c', 'a']);
268
+ * s.valueCounts(); // Series([3, 1, 1]) with index ['a', 'b', 'c']
269
+ * ```
270
+ */
271
+ valueCounts(): Series<number>;
272
+ /**
273
+ * Calculate the sum of all values.
274
+ *
275
+ * Skips null, undefined, and NaN values.
276
+ *
277
+ * @returns Sum of all numeric values.
278
+ * @throws {DataValidationError} If Series is empty or contains non-numeric data
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * const s = new Series([1, 2, null, 3, 4]);
283
+ * s.sum(); // 10
284
+ * ```
285
+ */
286
+ sum(): number;
287
+ /**
288
+ * Calculate the arithmetic mean (average) of all values.
289
+ *
290
+ * Skips null, undefined, and NaN values.
291
+ *
292
+ * @returns Mean of all numeric values.
293
+ * @throws {DataValidationError} If Series is empty or contains non-numeric data
294
+ *
295
+ * @example
296
+ * ```ts
297
+ * const s = new Series([1, 2, null, 3, 4]);
298
+ * s.mean(); // 2.5
299
+ * ```
300
+ */
301
+ mean(): number;
302
+ /**
303
+ * Calculate the median (middle value) of all values.
304
+ *
305
+ * Skips null, undefined, and NaN values.
306
+ * For even-length Series, returns the average of the two middle values.
307
+ *
308
+ * @returns Median value.
309
+ * @throws {DataValidationError} If Series is empty or contains non-numeric data
310
+ *
311
+ * @example
312
+ * ```ts
313
+ * const s = new Series([1, 2, 3, 4, 5]);
314
+ * s.median(); // 3
315
+ * ```
316
+ */
317
+ median(): number;
318
+ /**
319
+ * Calculate the standard deviation of all values.
320
+ *
321
+ * Skips null, undefined, and NaN values.
322
+ * Uses sample standard deviation (divides by n-1).
323
+ *
324
+ * @returns Standard deviation.
325
+ * @throws {DataValidationError} If Series is empty or contains non-numeric data
326
+ *
327
+ * @example
328
+ * ```ts
329
+ * const s = new Series([2, 4, 6, 8]);
330
+ * s.std(); // ~2.58
331
+ * ```
332
+ */
333
+ std(): number;
334
+ /**
335
+ * Calculate the variance of all values.
336
+ *
337
+ * Skips null, undefined, and NaN values.
338
+ * Uses sample variance (divides by n-1).
339
+ *
340
+ * @returns Variance.
341
+ * @throws {DataValidationError} If Series is empty or contains non-numeric data
342
+ *
343
+ * @example
344
+ * ```ts
345
+ * const s = new Series([2, 4, 6, 8]);
346
+ * s.var(); // ~6.67
347
+ * ```
348
+ */
349
+ var(): number;
350
+ /**
351
+ * Find the minimum value in the Series.
352
+ *
353
+ * Skips null, undefined, and NaN values.
354
+ *
355
+ * @returns Minimum value.
356
+ * @throws {DataValidationError} If Series is empty or contains non-numeric data
357
+ *
358
+ * @example
359
+ * ```ts
360
+ * const s = new Series([5, 2, 8, 1, 9]);
361
+ * s.min(); // 1
362
+ * ```
363
+ */
364
+ min(): number;
365
+ /**
366
+ * Find the maximum value in the Series.
367
+ *
368
+ * Skips null, undefined, and NaN values.
369
+ *
370
+ * @returns Maximum value.
371
+ * @throws {DataValidationError} If Series is empty or contains non-numeric data
372
+ *
373
+ * @example
374
+ * ```ts
375
+ * const s = new Series([5, 2, 8, 1, 9]);
376
+ * s.max(); // 9
377
+ * ```
378
+ */
379
+ max(): number;
380
+ /**
381
+ * Convert the Series to a plain JavaScript array.
382
+ *
383
+ * Returns a shallow copy of the data.
384
+ *
385
+ * @returns Array copy of the data
386
+ *
387
+ * @example
388
+ * ```ts
389
+ * const s = new Series([1, 2, 3]);
390
+ * const arr = s.toArray(); // [1, 2, 3]
391
+ * ```
392
+ */
393
+ toArray(): T[];
394
+ /**
395
+ * Convert the Series to an ndarray Tensor.
396
+ *
397
+ * Uses the `tensor()` factory function.
398
+ *
399
+ * @returns Tensor containing the Series data
400
+ * @throws {DataValidationError} If data cannot be converted to Tensor
401
+ *
402
+ * @example
403
+ * ```ts
404
+ * import { Series } from 'deepbox/dataframe';
405
+ *
406
+ * const s = new Series([1, 2, 3, 4]);
407
+ * const t = s.toTensor(); // Tensor([1, 2, 3, 4])
408
+ * ```
409
+ */
410
+ toTensor(): Tensor;
411
+ /**
412
+ * Return a human-readable string representation of this Series.
413
+ *
414
+ * Each row is printed as `index value`, with an optional name/dtype
415
+ * footer. Large Series are truncated with an ellipsis.
416
+ *
417
+ * @param maxRows - Maximum rows to display before summarizing (default: 20).
418
+ * @returns Formatted string representation
419
+ *
420
+ * @example
421
+ * ```ts
422
+ * const s = new Series([10, 20, 30], { name: 'values' });
423
+ * s.toString();
424
+ * // "0 10\n1 20\n2 30\nName: values, Length: 3"
425
+ * ```
426
+ */
427
+ toString(maxRows?: number): string;
428
+ }
429
+
430
+ /**
431
+ * Two-dimensional, size-mutable, potentially heterogeneous tabular data.
432
+ *
433
+ * A DataFrame is like a spreadsheet or SQL table. It consists of:
434
+ * - Rows (observations) identified by an index
435
+ * - Columns (variables) identified by column names
436
+ * - Data stored in a columnar format for efficient access
437
+ *
438
+ * Similar to pandas DataFrame in Python.
439
+ *
440
+ * @example
441
+ * ```ts
442
+ * import { DataFrame } from 'deepbox/dataframe';
443
+ *
444
+ * const df = new DataFrame({
445
+ * name: ['Alice', 'Bob', 'Charlie'],
446
+ * age: [25, 30, 35],
447
+ * score: [85.5, 92.0, 78.5]
448
+ * });
449
+ *
450
+ * console.log(df.shape); // [3, 3]
451
+ * console.log(df.columns); // ['name', 'age', 'score']
452
+ * ```
453
+ *
454
+ * @see {@link https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html | Pandas DataFrame}
455
+ */
456
+ declare class DataFrame {
457
+ private _data;
458
+ private _index;
459
+ private _indexPos;
460
+ private _columns;
461
+ /**
462
+ * Creates a new DataFrame instance.
463
+ *
464
+ * @param data - Object mapping column names to arrays of values.
465
+ * All arrays must have the same length.
466
+ * @param options - Configuration options
467
+ * @param options.columns - Custom column order (defaults to Object.keys(data))
468
+ * @param options.index - Custom row labels (defaults to 0, 1, 2, ...)
469
+ *
470
+ * @example
471
+ * ```ts
472
+ * const df = new DataFrame({
473
+ * col1: [1, 2, 3],
474
+ * col2: ['a', 'b', 'c']
475
+ * }, {
476
+ * index: ['row1', 'row2', 'row3']
477
+ * });
478
+ * ```
479
+ */
480
+ constructor(data: DataFrameData, options?: DataFrameOptions);
481
+ /**
482
+ * Get the dimensions of the DataFrame.
483
+ *
484
+ * @returns Tuple of [rows, columns]
485
+ *
486
+ * @example
487
+ * ```ts
488
+ * const df = new DataFrame({ a: [1, 2, 3], b: [4, 5, 6] });
489
+ * df.shape; // [3, 2]
490
+ * ```
491
+ */
492
+ get shape(): [number, number];
493
+ /**
494
+ * Get the column names.
495
+ *
496
+ * @returns Array of column names (copy)
497
+ */
498
+ get columns(): string[];
499
+ /**
500
+ * Get the row index labels.
501
+ *
502
+ * @returns Array of index labels (copy)
503
+ */
504
+ get index(): (string | number)[];
505
+ /**
506
+ * Get a column as a Series.
507
+ *
508
+ * @param column - Column name to retrieve
509
+ * @returns Series containing the column data
510
+ * @throws {InvalidParameterError} If column doesn't exist
511
+ *
512
+ * @example
513
+ * ```ts
514
+ * const df = new DataFrame({ age: [25, 30, 35], name: ['Alice', 'Bob', 'Carol'] });
515
+ * const ageSeries = df.get('age'); // Series([25, 30, 35])
516
+ * ```
517
+ */
518
+ get(column: string): Series<unknown>;
519
+ get<T>(column: string, guard: (value: unknown) => value is T): Series<T>;
520
+ /**
521
+ * Access a row by label (label-based indexing).
522
+ *
523
+ * @param row - The index label of the row
524
+ * @returns Object mapping column names to values for that row
525
+ * @throws {IndexError} If row label not found
526
+ *
527
+ * @example
528
+ * ```ts
529
+ * const df = new DataFrame(
530
+ * { age: [25, 30], name: ['Alice', 'Bob'] },
531
+ * { index: ['row1', 'row2'] }
532
+ * );
533
+ * df.loc('row1'); // { age: 25, name: 'Alice' }
534
+ * ```
535
+ */
536
+ loc(row: string | number): Record<string, unknown>;
537
+ /**
538
+ * Access a row by integer position (position-based indexing).
539
+ *
540
+ * @param position - The integer position (0-based)
541
+ * @returns Object mapping column names to values for that row
542
+ * @throws {IndexError} If position is out of bounds
543
+ *
544
+ * @example
545
+ * ```ts
546
+ * const df = new DataFrame({ age: [25, 30], name: ['Alice', 'Bob'] });
547
+ * df.iloc(0); // { age: 25, name: 'Alice' }
548
+ * df.iloc(1); // { age: 30, name: 'Bob' }
549
+ * ```
550
+ */
551
+ iloc(position: number): Record<string, unknown>;
552
+ /**
553
+ * Return the first n rows.
554
+ *
555
+ * @param n - Number of rows to return (default: 5)
556
+ * @returns New DataFrame with first n rows
557
+ *
558
+ * @example
559
+ * ```ts
560
+ * const df = new DataFrame({ a: [1, 2, 3, 4, 5], b: [6, 7, 8, 9, 10] });
561
+ * df.head(3); // DataFrame with rows 0-2
562
+ * ```
563
+ */
564
+ head(n?: number): DataFrame;
565
+ /**
566
+ * Return the last n rows.
567
+ *
568
+ * @param n - Number of rows to return (default: 5)
569
+ * @returns New DataFrame with last n rows
570
+ *
571
+ * @example
572
+ * ```ts
573
+ * const df = new DataFrame({ a: [1, 2, 3, 4, 5], b: [6, 7, 8, 9, 10] });
574
+ * df.tail(3); // DataFrame with rows 2-4
575
+ * ```
576
+ */
577
+ tail(n?: number): DataFrame;
578
+ /**
579
+ * Filter rows based on a boolean predicate function.
580
+ *
581
+ * @param predicate - Function that returns true for rows to keep
582
+ * @returns New DataFrame with filtered rows
583
+ *
584
+ * @example
585
+ * ```ts
586
+ * const df = new DataFrame({ age: [25, 30, 35], name: ['Alice', 'Bob', 'Carol'] });
587
+ * const filtered = df.filter(row => row.age > 28);
588
+ * // DataFrame with Bob and Carol
589
+ * ```
590
+ */
591
+ filter(predicate: (row: Record<string, unknown>) => boolean): DataFrame;
592
+ /**
593
+ * Select a subset of columns.
594
+ *
595
+ * @param columns - Array of column names to select
596
+ * @returns New DataFrame with only specified columns
597
+ * @throws {InvalidParameterError} If any column doesn't exist
598
+ *
599
+ * @example
600
+ * ```ts
601
+ * const df = new DataFrame({ a: [1, 2], b: [3, 4], c: [5, 6] });
602
+ * df.select(['a', 'c']); // DataFrame with only columns a and c
603
+ * ```
604
+ */
605
+ select(columns: string[]): DataFrame;
606
+ /**
607
+ * Drop (remove) specified columns.
608
+ *
609
+ * @param columns - Array of column names to drop
610
+ * @returns New DataFrame without the dropped columns
611
+ *
612
+ * @example
613
+ * ```ts
614
+ * const df = new DataFrame({ a: [1, 2], b: [3, 4], c: [5, 6] });
615
+ * df.drop(['b']); // DataFrame with only columns a and c
616
+ * ```
617
+ */
618
+ drop(columns: string[]): DataFrame;
619
+ /**
620
+ * Sort DataFrame by one or more columns.
621
+ *
622
+ * @param by - Column name or array of column names to sort by
623
+ * @param ascending - Sort in ascending order (default: true)
624
+ * @returns New sorted DataFrame
625
+ *
626
+ * @example
627
+ * ```ts
628
+ * const df = new DataFrame({ age: [30, 25, 35], name: ['Bob', 'Alice', 'Carol'] });
629
+ * df.sort('age'); // Sorted by age ascending
630
+ * df.sort(['age'], false); // Sorted by age descending
631
+ * ```
632
+ */
633
+ sort(by: string | string[], ascending?: boolean): DataFrame;
634
+ /**
635
+ * Group DataFrame by one or more columns.
636
+ *
637
+ * Returns a DataFrameGroupBy object for performing aggregations.
638
+ *
639
+ * @param by - Column name or array of column names to group by
640
+ * @returns DataFrameGroupBy object for aggregation operations
641
+ *
642
+ * @example
643
+ * ```ts
644
+ * const df = new DataFrame({
645
+ * category: ['A', 'B', 'A', 'B'],
646
+ * value: [10, 20, 30, 40]
647
+ * });
648
+ * const grouped = df.groupBy('category');
649
+ * grouped.sum(); // Sum values by category
650
+ * ```
651
+ */
652
+ groupBy(by: string | string[]): DataFrameGroupBy;
653
+ /**
654
+ * Join with another DataFrame using SQL-style join.
655
+ *
656
+ * Uses hash join algorithm for O(n + m) time complexity.
657
+ * Optimized for large datasets with minimal memory overhead.
658
+ *
659
+ * @param other - DataFrame to join with
660
+ * @param on - Column name to join on (must exist in both DataFrames)
661
+ * @param how - Type of join operation
662
+ * - 'inner': Only rows with matching keys in both DataFrames
663
+ * - 'left': All rows from left, matched rows from right (nulls for non-matches)
664
+ * - 'right': All rows from right, matched rows from left (nulls for non-matches)
665
+ * - 'outer': All rows from both DataFrames (nulls for non-matches)
666
+ * @returns New DataFrame with joined data
667
+ *
668
+ * @throws {InvalidParameterError} If join column doesn't exist in either DataFrame
669
+ *
670
+ * @example
671
+ * ```ts
672
+ * const customers = new DataFrame({
673
+ * id: [1, 2, 3],
674
+ * name: ['Alice', 'Bob', 'Charlie']
675
+ * });
676
+ * const orders = new DataFrame({
677
+ * id: [1, 1, 2, 4],
678
+ * product: ['Laptop', 'Mouse', 'Keyboard', 'Monitor']
679
+ * });
680
+ *
681
+ * // Inner join - only customers with orders
682
+ * const inner = customers.join(orders, 'id', 'inner');
683
+ * // Result: Alice with 2 orders, Bob with 1 order
684
+ *
685
+ * // Left join - all customers, with/without orders
686
+ * const left = customers.join(orders, 'id', 'left');
687
+ * // Result: Alice, Bob, Charlie (Charlie has null for product)
688
+ * ```
689
+ *
690
+ * @see {@link https://en.wikipedia.org/wiki/Hash_join | Hash Join Algorithm}
691
+ */
692
+ join(other: DataFrame, on: string, how?: "inner" | "left" | "right" | "outer"): DataFrame;
693
+ /**
694
+ * Merge with another DataFrame using pandas-style merge.
695
+ *
696
+ * More flexible than join() - supports different column names for join keys.
697
+ * Uses hash join algorithm for O(n + m) complexity.
698
+ *
699
+ * @param other - DataFrame to merge with
700
+ * @param options - Merge configuration
701
+ * - on: Column name to join on (must exist in both DataFrames)
702
+ * - left_on: Column name in left DataFrame
703
+ * - right_on: Column name in right DataFrame
704
+ * - how: Join type ('inner', 'left', 'right', 'outer')
705
+ * - suffixes: Suffix for duplicate column names ['_x', '_y']
706
+ * @returns New DataFrame with merged data
707
+ *
708
+ * @throws {InvalidParameterError} If merge columns don't exist or conflicting options provided
709
+ *
710
+ * @example
711
+ * ```ts
712
+ * const employees = new DataFrame({
713
+ * emp_id: [1, 2, 3],
714
+ * name: ['Alice', 'Bob', 'Charlie']
715
+ * });
716
+ * const salaries = new DataFrame({
717
+ * employee_id: [1, 2, 4],
718
+ * salary: [50000, 60000, 55000]
719
+ * });
720
+ *
721
+ * // Merge on different column names
722
+ * const result = employees.merge(salaries, {
723
+ * left_on: 'emp_id',
724
+ * right_on: 'employee_id',
725
+ * how: 'left'
726
+ * });
727
+ * ```
728
+ *
729
+ * @see {@link https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.merge.html | Pandas merge}
730
+ */
731
+ merge(other: DataFrame, options?: {
732
+ readonly on?: string;
733
+ readonly left_on?: string;
734
+ readonly right_on?: string;
735
+ readonly how?: "inner" | "left" | "right" | "outer";
736
+ readonly suffixes?: readonly [string, string];
737
+ }): DataFrame;
738
+ /**
739
+ * Concatenate with another DataFrame.
740
+ *
741
+ * @param other - DataFrame to concatenate
742
+ * @param axis - Axis to concatenate along.
743
+ * - 0 or "rows" or "index": Stack vertically (append rows)
744
+ * - 1 or "columns": Stack horizontally (append columns)
745
+ * @returns Concatenated DataFrame
746
+ *
747
+ * @example
748
+ * ```ts
749
+ * const df1 = new DataFrame({ a: [1, 2], b: [3, 4] });
750
+ * const df2 = new DataFrame({ a: [5, 6], b: [7, 8] });
751
+ * df1.concat(df2, "rows"); // Stack vertically: 4 rows
752
+ * df1.concat(df2, "columns"); // Stack horizontally: 4 columns
753
+ * ```
754
+ */
755
+ concat(other: DataFrame, axis?: Axis): DataFrame;
756
+ /**
757
+ * Fill missing values (null or undefined) with a specified value.
758
+ *
759
+ * @param value - Value to use for filling missing values
760
+ * @returns New DataFrame with missing values filled
761
+ *
762
+ * @example
763
+ * ```ts
764
+ * const df = new DataFrame({ a: [1, null, 3], b: [4, 5, undefined] });
765
+ * df.fillna(0); // Replace null/undefined with 0
766
+ * ```
767
+ */
768
+ fillna(value: unknown): DataFrame;
769
+ /**
770
+ * Drop rows that contain any missing values (null or undefined).
771
+ *
772
+ * @returns New DataFrame with rows containing missing values removed
773
+ *
774
+ * @example
775
+ * ```ts
776
+ * const df = new DataFrame({ a: [1, null, 3], b: [4, 5, 6] });
777
+ * df.dropna(); // Only keeps rows 0 and 2
778
+ * ```
779
+ */
780
+ dropna(): DataFrame;
781
+ /**
782
+ * Generate descriptive statistics.
783
+ *
784
+ * Computes count, mean, std, min, 25%, 50%, 75%, max for numeric columns.
785
+ *
786
+ * @returns DataFrame with statistics
787
+ */
788
+ describe(): DataFrame;
789
+ /**
790
+ * Compute correlation matrix.
791
+ *
792
+ * Uses pairwise complete observations (ignores missing values for each pair).
793
+ *
794
+ * @returns DataFrame containing pairwise correlations
795
+ */
796
+ corr(): DataFrame;
797
+ /**
798
+ * Compute covariance matrix.
799
+ *
800
+ * Uses pairwise complete observations.
801
+ *
802
+ * @returns DataFrame containing pairwise covariances
803
+ */
804
+ cov(): DataFrame;
805
+ /**
806
+ * Apply a function along an axis of the DataFrame.
807
+ *
808
+ * When `axis=1`, the provided Series is indexed by column names.
809
+ *
810
+ * @param fn - Function to apply to each Series
811
+ * @param axis - Axis to apply along (0=columns, 1=rows)
812
+ * @returns New DataFrame with function applied
813
+ *
814
+ * @example
815
+ * ```ts
816
+ * const df = new DataFrame({ a: [1, 2, 3], b: [4, 5, 6] });
817
+ * // Apply function to each column
818
+ * df.apply(series => series.map(x => Number(x) * 2), 0);
819
+ * ```
820
+ */
821
+ apply<U = unknown>(fn: (series: Series<unknown>) => Series<U>, axis?: Axis): DataFrame;
822
+ /**
823
+ * Convert DataFrame to a 2D Tensor.
824
+ *
825
+ * All columns must contain numeric data.
826
+ *
827
+ * @returns 2D Tensor with shape [rows, columns]
828
+ * @throws {DataValidationError} If data is non-numeric
829
+ *
830
+ * @example
831
+ * ```ts
832
+ * const df = new DataFrame({ a: [1, 2, 3], b: [4, 5, 6] });
833
+ * const t = df.toTensor(); // 2D tensor [[1,4], [2,5], [3,6]]
834
+ * ```
835
+ */
836
+ toTensor(): Tensor;
837
+ /**
838
+ * Convert DataFrame to a 2D JavaScript array.
839
+ *
840
+ * Each inner array represents a row.
841
+ *
842
+ * @returns 2D array of values
843
+ *
844
+ * @example
845
+ * ```ts
846
+ * const df = new DataFrame({ a: [1, 2], b: [3, 4] });
847
+ * df.toArray(); // [[1, 3], [2, 4]]
848
+ * ```
849
+ */
850
+ toArray(): unknown[][];
851
+ /**
852
+ * Parse CSV string into DataFrame with full type inference and quote handling.
853
+ * Time complexity: O(n) where n is number of characters.
854
+ */
855
+ static fromCsvString(csvString: string, options?: {
856
+ readonly delimiter?: string;
857
+ readonly quoteChar?: string;
858
+ readonly hasHeader?: boolean;
859
+ readonly skipRows?: number;
860
+ }): DataFrame;
861
+ /**
862
+ * Read CSV file - environment-aware (Node.js fs or browser fetch).
863
+ * Time complexity: O(n) for file read + O(m) for parsing.
864
+ */
865
+ static readCsv(path: string, options?: {
866
+ readonly delimiter?: string;
867
+ readonly quoteChar?: string;
868
+ readonly hasHeader?: boolean;
869
+ readonly skipRows?: number;
870
+ }): Promise<DataFrame>;
871
+ /**
872
+ * Convert DataFrame to CSV string with proper quoting and escaping.
873
+ * Time complexity: O(n × m) where n is rows, m is columns.
874
+ */
875
+ toCsvString(options?: {
876
+ readonly delimiter?: string;
877
+ readonly quoteChar?: string;
878
+ readonly includeIndex?: boolean;
879
+ readonly header?: boolean;
880
+ }): string;
881
+ /**
882
+ * Write DataFrame to CSV file - environment-aware.
883
+ * Time complexity: O(n × m) for generation + O(k) for write.
884
+ */
885
+ toCsv(path: string, options?: {
886
+ readonly delimiter?: string;
887
+ readonly quoteChar?: string;
888
+ readonly includeIndex?: boolean;
889
+ readonly header?: boolean;
890
+ }): Promise<void>;
891
+ /**
892
+ * Serialize DataFrame to JSON string.
893
+ * Time complexity: O(n × m).
894
+ */
895
+ toJsonString(): string;
896
+ /**
897
+ * Create DataFrame from JSON string.
898
+ * Time complexity: O(n × m).
899
+ */
900
+ static fromJsonString(jsonStr: string): DataFrame;
901
+ /**
902
+ * Read JSON file - environment-aware.
903
+ * Time complexity: O(n) for file read + O(m) for parsing.
904
+ */
905
+ static readJson(path: string): Promise<DataFrame>;
906
+ /**
907
+ * Write DataFrame to JSON file - environment-aware.
908
+ * Time complexity: O(n × m) for generation + O(k) for write.
909
+ */
910
+ toJson(path: string): Promise<void>;
911
+ /**
912
+ * Create DataFrame from a Tensor.
913
+ *
914
+ * @param tensor - Tensor to convert (must be 1D or 2D)
915
+ * @param columns - Column names (optional). If provided, length must match tensor columns.
916
+ * @returns DataFrame
917
+ *
918
+ * @example
919
+ * ```ts
920
+ * import { tensor } from 'deepbox/ndarray';
921
+ *
922
+ * const t = tensor([[1, 2], [3, 4], [5, 6]]);
923
+ * const df = DataFrame.fromTensor(t, ['col1', 'col2']);
924
+ * ```
925
+ */
926
+ static fromTensor(tensor: Tensor, columns?: string[]): DataFrame;
927
+ /**
928
+ * Remove duplicate rows from DataFrame.
929
+ * Time complexity: O(n × m) where n is rows, m is columns.
930
+ *
931
+ * @param subset - Columns to consider for identifying duplicates (default: all columns)
932
+ * @param keep - Which duplicates to keep: 'first', 'last', or false (remove all)
933
+ * @returns New DataFrame with duplicates removed
934
+ *
935
+ * @example
936
+ * ```ts
937
+ * const df = new DataFrame({ a: [1, 1, 2], b: [3, 3, 4] });
938
+ * df.drop_duplicates(); // Keeps first occurrence: [[1, 3], [2, 4]]
939
+ * df.drop_duplicates(undefined, 'last'); // Keeps last occurrence
940
+ * ```
941
+ */
942
+ drop_duplicates(subset?: string[], keep?: "first" | "last" | false): DataFrame;
943
+ /**
944
+ * Return boolean Series indicating duplicate rows.
945
+ * Time complexity: O(n × m).
946
+ *
947
+ * @param subset - Columns to consider for identifying duplicates
948
+ * @param keep - Which duplicates to mark as False: 'first', 'last', or false (mark all)
949
+ * @returns Series of booleans (true = duplicate, false = unique)
950
+ *
951
+ * @example
952
+ * ```ts
953
+ * const df = new DataFrame({ a: [1, 1, 2], b: [3, 3, 4] });
954
+ * df.duplicated(); // Series([false, true, false])
955
+ * ```
956
+ */
957
+ duplicated(subset?: string[], keep?: "first" | "last" | false): Series<boolean>;
958
+ /**
959
+ * Rename columns or index labels.
960
+ * Time complexity: O(m) for columns, O(n) for index.
961
+ *
962
+ * @param mapper - Object mapping old names to new names, or function to transform names
963
+ * @param axis - 0 for index, 1 for columns
964
+ * @returns New DataFrame with renamed labels
965
+ *
966
+ * @example
967
+ * ```ts
968
+ * const df = new DataFrame({ a: [1, 2], b: [3, 4] });
969
+ * df.rename({ a: 'x', b: 'y' }, 1); // Rename columns a->x, b->y
970
+ * df.rename((name) => name.toUpperCase(), 1); // Uppercase all column names
971
+ * ```
972
+ */
973
+ rename(mapper: Record<string, string> | ((name: string) => string), axis?: 0 | 1): DataFrame;
974
+ /**
975
+ * Reset index to default integer index.
976
+ * Time complexity: O(n).
977
+ *
978
+ * @param drop - If true, don't add old index as column.
979
+ * If a column named "index" already exists, the new column will be
980
+ * named "index_1", "index_2", etc.
981
+ * @returns New DataFrame with reset index
982
+ *
983
+ * @example
984
+ * ```ts
985
+ * const df = new DataFrame({ a: [1, 2] }, { index: ['x', 'y'] });
986
+ * df.reset_index(); // Index becomes [0, 1], adds 'index' column with ['x', 'y']
987
+ * df.reset_index(true); // Index becomes [0, 1], no new column
988
+ * ```
989
+ */
990
+ reset_index(drop?: boolean): DataFrame;
991
+ /**
992
+ * Set a column as the index.
993
+ * Time complexity: O(n).
994
+ *
995
+ * @param column - Column name to use as index
996
+ * @param drop - If true, remove the column after setting it as index
997
+ * @returns New DataFrame with new index
998
+ *
999
+ * @example
1000
+ * ```ts
1001
+ * const df = new DataFrame({ id: ['a', 'b', 'c'], value: [1, 2, 3] });
1002
+ * df.set_index('id'); // Index becomes ['a', 'b', 'c']
1003
+ * ```
1004
+ */
1005
+ set_index(column: string, drop?: boolean): DataFrame;
1006
+ /**
1007
+ * Return boolean DataFrame showing null values.
1008
+ * Time complexity: O(n × m).
1009
+ *
1010
+ * @returns DataFrame of booleans (true = null/undefined, false = not null)
1011
+ *
1012
+ * @example
1013
+ * ```ts
1014
+ * const df = new DataFrame({ a: [1, null, 3], b: [4, 5, undefined] });
1015
+ * df.isnull(); // [[false, false], [true, false], [false, true]]
1016
+ * ```
1017
+ */
1018
+ isnull(): DataFrame;
1019
+ /**
1020
+ * Return boolean DataFrame showing non-null values.
1021
+ * Time complexity: O(n × m).
1022
+ *
1023
+ * @returns DataFrame of booleans (true = not null, false = null/undefined)
1024
+ *
1025
+ * @example
1026
+ * ```ts
1027
+ * const df = new DataFrame({ a: [1, null, 3], b: [4, 5, undefined] });
1028
+ * df.notnull(); // [[true, true], [false, true], [true, false]]
1029
+ * ```
1030
+ */
1031
+ notnull(): DataFrame;
1032
+ /**
1033
+ * Replace values in DataFrame.
1034
+ * Time complexity: O(n × m).
1035
+ *
1036
+ * @param toReplace - Value or array of values to replace
1037
+ * @param value - Replacement value
1038
+ * @returns New DataFrame with replaced values
1039
+ *
1040
+ * @example
1041
+ * ```ts
1042
+ * const df = new DataFrame({ a: [1, 2, 3], b: [4, 5, 6] });
1043
+ * df.replace(2, 99); // Replace all 2s with 99
1044
+ * df.replace([1, 2], 0); // Replace 1s and 2s with 0
1045
+ * ```
1046
+ */
1047
+ replace(toReplace: unknown | unknown[], value: unknown): DataFrame;
1048
+ /**
1049
+ * Clip (limit) values in a range.
1050
+ * Time complexity: O(n × m).
1051
+ *
1052
+ * @param lower - Minimum value (values below are set to this)
1053
+ * @param upper - Maximum value (values above are set to this)
1054
+ * @returns New DataFrame with clipped values
1055
+ *
1056
+ * @example
1057
+ * ```ts
1058
+ * const df = new DataFrame({ a: [1, 5, 10], b: [2, 8, 15] });
1059
+ * df.clip(3, 9); // [[3, 3], [5, 8], [9, 9]]
1060
+ * ```
1061
+ */
1062
+ clip(lower?: number, upper?: number): DataFrame;
1063
+ /**
1064
+ * Return a random sample of rows.
1065
+ * Time complexity: O(n) for sampling.
1066
+ *
1067
+ * @param n - Number of rows to sample
1068
+ * @param random_state - Random seed for reproducibility
1069
+ * @returns New DataFrame with sampled rows
1070
+ *
1071
+ * @example
1072
+ * ```ts
1073
+ * const df = new DataFrame({ a: [1, 2, 3, 4, 5], b: [6, 7, 8, 9, 10] });
1074
+ * df.sample(3); // Random 3 rows
1075
+ * ```
1076
+ */
1077
+ sample(n: number, random_state?: number): DataFrame;
1078
+ /**
1079
+ * Seeded random number generator for reproducibility.
1080
+ * @private
1081
+ */
1082
+ private seededRandom;
1083
+ /**
1084
+ * Return values at the given quantile.
1085
+ * Time complexity: O(n log n) per column due to sorting.
1086
+ *
1087
+ * @param q - Quantile to compute (0 to 1)
1088
+ * @returns Series with quantile values for each numeric column
1089
+ *
1090
+ * @example
1091
+ * ```ts
1092
+ * const df = new DataFrame({ a: [1, 2, 3, 4, 5], b: [10, 20, 30, 40, 50] });
1093
+ * df.quantile(0.5); // Median: Series({ a: 3, b: 30 })
1094
+ * df.quantile(0.25); // 25th percentile
1095
+ * ```
1096
+ */
1097
+ quantile(q: number): Series<number>;
1098
+ /**
1099
+ * Compute numerical rank of values (1 through n) along axis.
1100
+ * Time complexity: O(n log n) per column.
1101
+ *
1102
+ * @param method - How to rank ties: 'average', 'min', 'max', 'first', 'dense'
1103
+ * @param ascending - Rank in ascending order
1104
+ * @returns New DataFrame with ranks
1105
+ *
1106
+ * @example
1107
+ * ```ts
1108
+ * const df = new DataFrame({ a: [3, 1, 2, 1] });
1109
+ * df.rank(); // [[4], [1.5], [3], [1.5]] (average method)
1110
+ * df.rank('min'); // [[4], [1], [3], [1]]
1111
+ * ```
1112
+ */
1113
+ rank(method?: "average" | "min" | "max" | "first" | "dense", ascending?: boolean): DataFrame;
1114
+ /**
1115
+ * Calculate the difference between consecutive rows.
1116
+ * Time complexity: O(n × m).
1117
+ *
1118
+ * @param periods - Number of periods to shift (default: 1)
1119
+ * @returns New DataFrame with differences
1120
+ *
1121
+ * @example
1122
+ * ```ts
1123
+ * const df = new DataFrame({ a: [1, 3, 6, 10] });
1124
+ * df.diff(); // [[null], [2], [3], [4]]
1125
+ * df.diff(2); // [[null], [null], [5], [7]]
1126
+ * ```
1127
+ */
1128
+ diff(periods?: number): DataFrame;
1129
+ /**
1130
+ * Calculate percentage change between consecutive rows.
1131
+ * Time complexity: O(n × m).
1132
+ *
1133
+ * @param periods - Number of periods to shift (default: 1)
1134
+ * @returns New DataFrame with percentage changes
1135
+ *
1136
+ * @example
1137
+ * ```ts
1138
+ * const df = new DataFrame({ a: [100, 110, 121] });
1139
+ * df.pct_change(); // [[null], [0.1], [0.1]] (10% increase each time)
1140
+ * ```
1141
+ */
1142
+ pct_change(periods?: number): DataFrame;
1143
+ /**
1144
+ * Return cumulative sum over DataFrame axis.
1145
+ * Time complexity: O(n × m).
1146
+ *
1147
+ * @returns New DataFrame with cumulative sums
1148
+ *
1149
+ * @example
1150
+ * ```ts
1151
+ * const df = new DataFrame({ a: [1, 2, 3], b: [4, 5, 6] });
1152
+ * df.cumsum(); // [[1, 4], [3, 9], [6, 15]]
1153
+ * ```
1154
+ */
1155
+ cumsum(): DataFrame;
1156
+ /**
1157
+ * Return cumulative product over DataFrame axis.
1158
+ * Time complexity: O(n × m).
1159
+ *
1160
+ * @returns New DataFrame with cumulative products
1161
+ *
1162
+ * @example
1163
+ * ```ts
1164
+ * const df = new DataFrame({ a: [2, 3, 4] });
1165
+ * df.cumprod(); // [[2], [6], [24]]
1166
+ * ```
1167
+ */
1168
+ cumprod(): DataFrame;
1169
+ /**
1170
+ * Return cumulative maximum over DataFrame axis.
1171
+ * Time complexity: O(n × m).
1172
+ *
1173
+ * @returns New DataFrame with cumulative maximums
1174
+ *
1175
+ * @example
1176
+ * ```ts
1177
+ * const df = new DataFrame({ a: [3, 1, 5, 2] });
1178
+ * df.cummax(); // [[3], [3], [5], [5]]
1179
+ * ```
1180
+ */
1181
+ cummax(): DataFrame;
1182
+ /**
1183
+ * Return cumulative minimum over DataFrame axis.
1184
+ * Time complexity: O(n × m).
1185
+ *
1186
+ * @returns New DataFrame with cumulative minimums
1187
+ *
1188
+ * @example
1189
+ * ```ts
1190
+ * const df = new DataFrame({ a: [3, 1, 5, 2] });
1191
+ * df.cummin(); // [[3], [1], [1], [1]]
1192
+ * ```
1193
+ */
1194
+ cummin(): DataFrame;
1195
+ /**
1196
+ * Shift index by desired number of periods.
1197
+ * Time complexity: O(n × m).
1198
+ *
1199
+ * @param periods - Number of periods to shift (positive = down, negative = up)
1200
+ * @param fill_value - Value to use for newly introduced missing values
1201
+ * @returns New DataFrame with shifted data
1202
+ *
1203
+ * @example
1204
+ * ```ts
1205
+ * const df = new DataFrame({ a: [1, 2, 3, 4] });
1206
+ * df.shift(1); // [[null], [1], [2], [3]]
1207
+ * df.shift(-1); // [[2], [3], [4], [null]]
1208
+ * df.shift(1, 0); // [[0], [1], [2], [3]]
1209
+ * ```
1210
+ */
1211
+ shift(periods?: number, fill_value?: unknown): DataFrame;
1212
+ /**
1213
+ * Pivot DataFrame.
1214
+ * Time complexity: O(n × m).
1215
+ *
1216
+ * @param index - Column to use as index
1217
+ * @param columns - Column to use as column headers
1218
+ * @param values - Column to use as values
1219
+ * @returns New DataFrame with pivoted data
1220
+ *
1221
+ * @example
1222
+ * ```ts
1223
+ * const df = new DataFrame({
1224
+ * country: ['USA', 'USA', 'Canada', 'Canada'],
1225
+ * year: [2010, 2011, 2010, 2011],
1226
+ * value: [100, 200, 300, 400]
1227
+ * });
1228
+ * df.pivot('country', 'year', 'value');
1229
+ * // country | 2010 | 2011
1230
+ * // USA | 100 | 200
1231
+ * // Canada | 300 | 400
1232
+ * ```
1233
+ */
1234
+ pivot(index: string, columns: string, values: string): DataFrame;
1235
+ /**
1236
+ * Melt DataFrame.
1237
+ * Time complexity: O(n × m).
1238
+ *
1239
+ * @param id_vars - Columns to keep as is
1240
+ * @param value_vars - Columns to melt
1241
+ * @param var_name - Name for new column with melted variable names
1242
+ * @param value_name - Name for new column with melted values.
1243
+ * Must not conflict with existing columns or var_name.
1244
+ * @returns New DataFrame with melted data
1245
+ *
1246
+ * @example
1247
+ * ```ts
1248
+ * const df = new DataFrame({
1249
+ * id: ['a', 'b'],
1250
+ * x: [1, 2],
1251
+ * y: [3, 4]
1252
+ * });
1253
+ * df.melt(['id'], ['x', 'y'], 'variable', 'value');
1254
+ * // id | variable | value
1255
+ * // a | x | 1
1256
+ * // a | y | 3
1257
+ * // b | x | 2
1258
+ * // b | y | 4
1259
+ * ```
1260
+ */
1261
+ melt(id_vars: string[], value_vars: string[], var_name?: string, value_name?: string): DataFrame;
1262
+ /**
1263
+ * Rolling window mean calculation.
1264
+ *
1265
+ * @param window - Size of the rolling window
1266
+ * @param on - Column to apply rolling calculation to (if omitted, applies to all columns)
1267
+ * @returns New DataFrame with rolling mean values
1268
+ *
1269
+ * @example
1270
+ * ```ts
1271
+ * const df = new DataFrame({ a: [1, 2, 3, 4, 5] });
1272
+ * df.rolling(3); // [[null], [null], [2], [3], [4]]
1273
+ * ```
1274
+ */
1275
+ rolling(window: number, on?: string): DataFrame;
1276
+ /**
1277
+ * Return a human-readable tabular string representation.
1278
+ *
1279
+ * Columns are right-aligned and padded so that rows line up.
1280
+ * Large DataFrames are truncated with an ellipsis row.
1281
+ *
1282
+ * @param maxRows - Maximum rows to display before summarizing (default: 20).
1283
+ * @returns Formatted table string
1284
+ *
1285
+ * @example
1286
+ * ```ts
1287
+ * const df = new DataFrame({ a: [1, 2], b: [3, 4] });
1288
+ * df.toString();
1289
+ * // " a b\n0 1 3\n1 2 4"
1290
+ * ```
1291
+ */
1292
+ toString(maxRows?: number): string;
1293
+ }
1294
+ /**
1295
+ * GroupBy object for aggregation operations.
1296
+ *
1297
+ * Created by DataFrame.groupBy(). Used to perform aggregations on grouped data.
1298
+ *
1299
+ * @example
1300
+ * ```ts
1301
+ * const df = new DataFrame({
1302
+ * category: ['A', 'B', 'A', 'B'],
1303
+ * value: [10, 20, 30, 40]
1304
+ * });
1305
+ * const grouped = df.groupBy('category');
1306
+ * grouped.sum(); // Sum by category
1307
+ * grouped.mean(); // Mean by category
1308
+ * ```
1309
+ */
1310
+ declare class DataFrameGroupBy {
1311
+ private groupMap;
1312
+ private keyValuesMap;
1313
+ private df;
1314
+ private by;
1315
+ constructor(df: DataFrame, by: string | string[]);
1316
+ /**
1317
+ * Build the grouping map: group key -> array of row indices.
1318
+ *
1319
+ * @private
1320
+ */
1321
+ private buildGroupMap;
1322
+ /**
1323
+ * Aggregate grouped data.
1324
+ *
1325
+ * @param operations - Dictionary of column name to aggregation function
1326
+ * @returns New DataFrame with aggregated data
1327
+ *
1328
+ * @example
1329
+ * ```ts
1330
+ * const grouped = df.groupBy('category');
1331
+ * const result = grouped.agg({ value: 'sum', count: 'count' });
1332
+ * ```
1333
+ */
1334
+ agg(operations: Record<string, AggregateFunction | AggregateFunction[]>): DataFrame;
1335
+ /**
1336
+ * Helper to identify numeric columns (excluding grouping columns).
1337
+ * @private
1338
+ */
1339
+ private getNumericColumns;
1340
+ /**
1341
+ * Helper method to perform same aggregation on all numeric non-grouping columns.
1342
+ * @private
1343
+ */
1344
+ private aggNumeric;
1345
+ /**
1346
+ * Helper method to perform same aggregation on all non-grouping columns.
1347
+ *
1348
+ * @private
1349
+ */
1350
+ private aggAll;
1351
+ /**
1352
+ * Compute sum for each group.
1353
+ *
1354
+ * @returns DataFrame with summed values by group
1355
+ *
1356
+ * @example
1357
+ * ```ts
1358
+ * const df = new DataFrame({
1359
+ * category: ['A', 'A', 'B', 'B'],
1360
+ * value: [1, 2, 3, 4]
1361
+ * });
1362
+ * df.groupBy('category').sum();
1363
+ * // category | value
1364
+ * // A | 3
1365
+ * // B | 7
1366
+ * ```
1367
+ */
1368
+ sum(): DataFrame;
1369
+ /**
1370
+ * Compute mean (average) for each group.
1371
+ *
1372
+ * @returns DataFrame with mean values by group
1373
+ */
1374
+ mean(): DataFrame;
1375
+ /**
1376
+ * Count non-null values in each non-grouping column for every group.
1377
+ *
1378
+ * @returns DataFrame with per-column non-null counts by group
1379
+ */
1380
+ count(): DataFrame;
1381
+ /**
1382
+ * Compute minimum value for each group.
1383
+ *
1384
+ * @returns DataFrame with minimum values by group
1385
+ */
1386
+ min(): DataFrame;
1387
+ /**
1388
+ * Compute maximum value for each group.
1389
+ *
1390
+ * @returns DataFrame with maximum values by group
1391
+ */
1392
+ max(): DataFrame;
1393
+ /**
1394
+ * Compute standard deviation for each group.
1395
+ *
1396
+ * @returns DataFrame with standard deviation values by group
1397
+ */
1398
+ std(): DataFrame;
1399
+ /**
1400
+ * Compute variance for each group.
1401
+ *
1402
+ * @returns DataFrame with variance values by group
1403
+ */
1404
+ var(): DataFrame;
1405
+ /**
1406
+ * Compute median for each group.
1407
+ *
1408
+ * @returns DataFrame with median values by group
1409
+ */
1410
+ median(): DataFrame;
1411
+ }
1412
+
1413
+ type index_AggregateFunction = AggregateFunction;
1414
+ type index_DataFrame = DataFrame;
1415
+ declare const index_DataFrame: typeof DataFrame;
1416
+ type index_DataFrameData = DataFrameData;
1417
+ type index_DataFrameGroupBy = DataFrameGroupBy;
1418
+ declare const index_DataFrameGroupBy: typeof DataFrameGroupBy;
1419
+ type index_DataFrameOptions = DataFrameOptions;
1420
+ type index_Series<T = unknown> = Series<T>;
1421
+ declare const index_Series: typeof Series;
1422
+ type index_SeriesOptions = SeriesOptions;
1423
+ declare namespace index {
1424
+ export { type index_AggregateFunction as AggregateFunction, index_DataFrame as DataFrame, type index_DataFrameData as DataFrameData, index_DataFrameGroupBy as DataFrameGroupBy, type index_DataFrameOptions as DataFrameOptions, index_Series as Series, type index_SeriesOptions as SeriesOptions };
1425
+ }
1426
+
1427
+ export { type AggregateFunction as A, DataFrame as D, Series as S, DataFrameGroupBy as a, type DataFrameData as b, type DataFrameOptions as c, type SeriesOptions as d, index as i };