-
-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathtypes.ts
More file actions
421 lines (398 loc) · 15.1 KB
/
types.ts
File metadata and controls
421 lines (398 loc) · 15.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
/**
* @license
* Copyright 2022 JsData. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ==========================================================================
*/
import { BaseUserConfig, TableUserConfig, } from "table"
import { Config, Layout } from "plotly.js-dist-min"
import { HeadersInit } from "node-fetch";
import Groupby from '../aggregators/groupby';
import { ParseConfig } from 'papaparse';
import DataFrame from '../core/frame';
import Series from '../core/series';
import Str from '../core/strings';
import Dt from '../core/datetime';
import { ParsingOptions, WritingOptions } from "xlsx";
export type DTYPES = "float32" | "int32" | "string" | "boolean" | "undefined"
export type ArrayType2D = Array<
number[]
| string[]
| boolean[]
| (number | string | boolean)[]>
export type ArrayType1D = Array<
number
| string
| boolean
| (number | string | boolean)>
//Start of Config class types
export type ConfigsType = {
tableDisplayConfig?: BaseUserConfig & TableUserConfig
tableMaxRow?: number;
tableMaxColInConsole?: number;
dtypeTestLim?: number;
lowMemoryMode?: boolean
tfInstance?: any
}
//End of Config class types
//Start of Generic class types
export interface BaseDataOptionType {
type?: number;
index?: Array<string | number>
columns?: string[]
dtypes?: Array<string>
config?: ConfigsType;
}
export interface NdframeInputDataType {
data: any
type?: number;
index?: Array<string | number>
columns?: string[]
dtypes?: Array<string>
config?: ConfigsType;
isSeries: boolean;
}
export interface LoadArrayDataType {
data: ArrayType1D | ArrayType2D
index?: Array<string | number>
columns?: string[]
dtypes?: Array<string>
}
export interface LoadObjectDataType {
data: object | Array<object>
type?: number;
index?: Array<string | number>
columns?: string[]
dtypes?: Array<string>
}
export type AxisType = {
index: Array<string | number>
columns: Array<string | number>
}
export interface NDframeInterface {
config?: ConfigsType;
$setDtypes(dtypes: Array<string>, infer: boolean): void;
$setIndex(index: Array<string | number>): void;
$resetIndex(): void;
$setColumnNames(columns: string[]): void
get dtypes(): Array<string>;
get ndim(): number;
get axis(): AxisType;
get index(): Array<string | number>;
get columns(): string[]
get shape(): Array<number>;
get values(): ArrayType1D | ArrayType2D
get tensor(): any
get size(): number;
print(): void;
}
//End of Generic class types
//Start of Series class types
type mapFunc = (val: any, i: number) => any[]
export type mapParam = object | mapFunc
export interface SeriesInterface extends NDframeInterface {
iloc(rows: Array<string | number> | boolean[]): Series;
head(rows: number): Series
tail(rows: number): Series
sample(num: number, options?: { seed?: number }): Promise<Series>;
add(other: Series | number | Array<number>, options?: { inplace?: boolean }): Series | void;
sub(other: Series | number | Array<number>, options?: { inplace?: boolean }): Series | void;
mul(other: Series | number | Array<number>, options?: { inplace?: boolean }): Series | void;
div(other: Series | number | Array<number>, options?: { inplace?: boolean }): Series | void;
pow(other: Series | number | Array<number>, options?: { inplace?: boolean }): Series | void;
mod(other: Series | number | Array<number>, options?: { inplace?: boolean }): Series | void;
mean(): number
median(): number
mode(): any
min(): number
max(): number
sum(): number
count(): number
maximum(other: Series | number | Array<number>): Series
minimum(other: Series | number | Array<number>): Series
round(dp: number, options?: { inplace?: boolean }): Series | void
std(): number
var(): number
isNa(): Series
fillNa(value: number | string | boolean, options?: { inplace?: boolean }): Series | void
sortValues(options?: { ascending?: boolean, inplace?: boolean }): Series | void
copy(): Series
describe(): Series
resetIndex(options?: { inplace?: boolean }): Series | void
setIndex(index: Array<number | string | (number | string)>, options?: { inplace?: boolean }): Series | void
map(
callable: mapParam,
options?: { inplace?: boolean })
: Series | void
apply(
callable: (value: any) => any,
options?: { inplace?: boolean }): Series | void
unique(): Series
nUnique(): number
valueCounts(): Series
abs(options?: { inplace?: boolean }): Series | void
cumSum(options?: { inplace?: boolean }): Series | void
cumMin(options?: { inplace?: boolean }): Series | void
cumMax(options?: { inplace?: boolean }): Series | void
cumProd(options?: { inplace?: boolean }): Series | void
countDistinct(options?: { inplace?: boolean }): Series | void
lt(other: Series | number | Array<number> | boolean[]): Series
gt(other: Series | number | Array<number> | boolean[]): Series
le(other: Series | number | Array<number> | boolean[]): Series
ge(other: Series | number | Array<number> | boolean[]): Series
ne(other: Series | number | Array<number> | boolean[]): Series
eq(other: Series | number | Array<number> | boolean[]): Series
replace(oldValue: string | number | boolean, newValue: string | number | boolean, options?: { inplace?: boolean }): Series | void
dropNa(options?: { inplace?: boolean }): Series | void
argSort(options?: { ascending: boolean }): Series
argMax(): number
argMin(): number
get dtype(): string
dropDuplicates(options?: { keep?: "first" | "last", inplace?: boolean }): Series | void
asType(dtype: "float32" | "int32" | "string" | "boolean", options?: { inplace?: boolean }): Series | void
get str(): Str
get dt(): Dt
append(values: string | number | boolean | Series | ArrayType1D,
index: Array<number | string> | number | string,
options?: { inplace?: boolean }): Series | void
toString(): string;
and(other: any): Series
or(other: any): Series
getDummies(options?: {
prefix?: string | Array<string>,
prefixSeparator?: string | Array<string>,
inplace?: boolean
}): DataFrame
iat(index: number): number | string | boolean | undefined
at(index: string | number): number | string | boolean | undefined
plot(divId: string): IPlotlyLib
}
//Start of DataFrame class types
export interface DataFrameInterface extends NDframeInterface {
[key: string]: any
drop(
options:
{
columns?: string | Array<string>,
index?: Array<string | number>,
inplace?: boolean
}
): DataFrame | void
loc(options:
{
rows?: Array<string | number>,
columns?: Array<string>
}): DataFrame;
iloc(options:
{
rows?: Array<string | number>,
columns?: Array<string | number>
}): DataFrame;
head(rows?: number): DataFrame
tail(rows?: number): DataFrame
sample(num: number, options?: { seed?: number }): Promise<DataFrame>;
add(other: DataFrame | Series | number | number[], options?: { axis?: 0 | 1, inplace?: boolean }): DataFrame | void
sub(other: DataFrame | Series | number | number[], options?: { axis?: 0 | 1, inplace?: boolean }): DataFrame | void
mul(other: DataFrame | Series | number | number[], options?: { axis?: 0 | 1, inplace?: boolean }): DataFrame | void
div(other: DataFrame | Series | number | number[], options?: { axis?: 0 | 1, inplace?: boolean }): DataFrame | void
divNoNan(other: DataFrame | Series | number | number[], options?: { axis?: 0 | 1, inplace?: boolean }): DataFrame | void
pow(other: DataFrame | Series | number | number[], options?: { axis?: 0 | 1, inplace?: boolean }): DataFrame | void
mod(other: DataFrame | Series | number | number[], options?: { axis?: 0 | 1, inplace?: boolean }): DataFrame | void
pctChange(other: DataFrame | Series | number[] | number, options?: { axis?: 0 | 1, inplace?: boolean }): DataFrame | void
diff(other: DataFrame | Series | number[] | number, options?: { axis?: 0 | 1, inplace?: boolean }): DataFrame | void
mean(options?: { axis?: 0 | 1 }): Series
median(options?: { axis?: 0 | 1 }): Series
mode(options?: { axis?: 0 | 1, keep?: number }): Series
min(options?: { axis?: 0 | 1 }): Series
max(options?: { axis?: 0 | 1 }): Series
std(options?: { axis?: 0 | 1 }): Series
var(options?: { axis?: 0 | 1 }): Series
sum(options?: { axis?: 0 | 1 }): Series
count(options?: { axis?: 0 | 1 }): Series
round(dp?: number, options?: { inplace: boolean }): DataFrame | void
cumSum(options?: { axis?: 0 | 1 }): DataFrame | void
cumMin(options?: { axis?: 0 | 1 }): DataFrame | void
cumMax(options?: { axis?: 0 | 1 }): DataFrame | void
cumProd(options?: { axis?: 0 | 1 }): DataFrame | void
countDistinct(options?: { axis?: 0 | 1 }): DataFrame | void
copy(): DataFrame
resetIndex(options: { inplace?: boolean }): DataFrame | void
setIndex(
options:
{
index: Array<number | string | (number | string)>,
column?: string,
drop?: boolean,
inplace?: boolean
}
): DataFrame | void
describe(): DataFrame
selectDtypes(include: Array<string>): DataFrame
abs(options?: { inplace?: boolean }): DataFrame | void
query(condition: Series | Array<boolean>, options?: { inplace?: boolean }): DataFrame | void
addColumn(
column: string,
values: Series | ArrayType1D,
options?: {
inplace?: boolean,
atIndex?: number | string
}
): DataFrame | void
groupby(col: Array<string>): Groupby
column(column: string): Series
fillNa(value: ArrayType1D,
options?:
{
columns?: Array<string>,
inplace?: boolean
}): DataFrame | void
isNa(): DataFrame
dropNa(options?: { axis: 0 | 1, inplace?: boolean }): DataFrame | void
apply(callable: any, options?: { axis?: 0 | 1 }): DataFrame | Series
applyMap(callable: any, options?: { inplace?: boolean }): DataFrame | void
lt(other: DataFrame | Series | number, options?: { axis?: 0 | 1 }): DataFrame
gt(other: DataFrame | Series | number, options?: { axis?: 0 | 1 }): DataFrame
le(other: DataFrame | Series | number, options?: { axis?: 0 | 1 }): DataFrame
ge(other: DataFrame | Series | number, options?: { axis?: 0 | 1 }): DataFrame
ne(other: DataFrame | Series | number, options?: { axis?: 0 | 1 }): DataFrame
eq(other: DataFrame | Series | number, options?: { axis?: 0 | 1 }): DataFrame
replace(
oldValue: number | string | boolean,
newValue: number | string | boolean,
options?: {
columns?: Array<string>
inplace?: boolean
}
): DataFrame | void
transpose(options?: { inplace?: boolean }): DataFrame | void
get T(): DataFrame
get ctypes(): Series
asType(
column: string,
dtype: "float32" | "int32" | "string" | "boolean",
options?: { inplace?: boolean }
): DataFrame | void
nUnique(axis: 0 | 1): Series
rename(
mapper: object,
options?: {
axis?: 0 | 1
inplace?: boolean
}
): DataFrame | void
sortIndex(options?:
{
inplace?: boolean
ascending?: boolean
}
): DataFrame | void
sortValues(
column: string,
options?:
{
inplace?: boolean
ascending?: boolean
}
): DataFrame | void
append(
newValues: ArrayType1D | ArrayType2D | Series | DataFrame,
index: Array<number | string> | number | string,
options?: {
inplace?: boolean,
}
): DataFrame | void
toString(): string;
getDummies(options?: {
columns?: string | Array<string>,
prefix?: string | Array<string>,
prefixSeparator?: string | Array<string>,
inplace?: boolean
}): DataFrame | void
iat(row: number, column: number): number | string | boolean | undefined
at(row: string | number, column: string): number | string | boolean | undefined
plot(divId: string): IPlotlyLib
}
export interface DateTime {
month(): Series
dayOfWeek(): Series
year(): Series
monthName(): Series
dayOfMonth(): Series
hours(): Series
seconds(): Series
minutes(): Series
date(): Series
}
interface CustomConfig extends Config {
x: string
y: string,
values: string,
labels: string,
rowPositions: number[],
columnPositions: number[],
grid: { rows: number, columns: number },
tableHeaderStyle: any,
tableCellStyle: any,
columns: string[];
}
export type PlotConfigObject = {
config?: Partial<CustomConfig>
layout?: Partial<Layout>
}
export type InternalPlotConfigObject = {
config: Partial<CustomConfig>
layout: Partial<Layout>
}
export interface IPlotlyLib {
line(plotConfig?: PlotConfigObject): void
bar(plotConfig?: PlotConfigObject): void
scatter(plotConfig?: PlotConfigObject): void
hist(plotConfig?: PlotConfigObject): void
pie(plotConfig?: PlotConfigObject): void
box(plotConfig?: PlotConfigObject): void
violin(plotConfig?: PlotConfigObject): void
table(plotConfig?: PlotConfigObject): void
}
export interface CsvInputOptionsBrowser extends ParseConfig {
frameConfig?: BaseDataOptionType
}
export type ExcelInputOptionsBrowser = {
sheet?: number,
method?: string,
headers?: any,
frameConfig?: BaseDataOptionType
parsingOptions?: ParsingOptions
}
export type JsonInputOptionsBrowser = {
method?: string,
headers?: any,
frameConfig?: BaseDataOptionType
}
export interface CsvInputOptionsNode extends ParseConfig {
frameConfig?: BaseDataOptionType
}
export type ExcelInputOptionsNode = {
sheet?: number,
method?: string,
headers?: HeadersInit
frameConfig?: BaseDataOptionType
parsingOptions?: ParsingOptions
}
export type JsonInputOptionsNode = {
method?: string,
headers?: HeadersInit
frameConfig?: BaseDataOptionType
}
export type CsvOutputOptionsBrowser = { fileName?: string, sep?: string, header?: boolean, download?: boolean };
export type ExcelOutputOptionsBrowser = { fileName?: string, sheetName?: string, writingOptions?: WritingOptions };
export type JsonOutputOptionsBrowser = { fileName?: string, format?: "row" | "column", download?: boolean };
export type CsvOutputOptionsNode = { filePath?: string, sep?: string, header?: boolean }
export type JsonOutputOptionsNode = { format?: "row" | "column", filePath?: string }
export type ExcelOutputOptionsNode = { filePath?: string, sheetName?: string, writingOptions?: WritingOptions }