df-script 1.4.0 → 1.6.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.
- package/README.md +203 -38
- package/dist/api.d.ts +16 -8
- package/dist/columnExpressions/ColumnExpr.d.ts +26 -364
- package/dist/columnExpressions/ExprBase.d.ts +8 -11
- package/dist/columnExpressions/constants.d.ts +2 -0
- package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
- package/dist/columnExpressions/functions/element.d.ts +5 -0
- package/dist/columnExpressions/functions/implode.d.ts +3 -0
- package/dist/columnExpressions/functions/lit.d.ts +3 -1
- package/dist/columnExpressions/functions/seq_range.d.ts +31 -0
- package/dist/columnExpressions/functions/when.d.ts +2 -2
- package/dist/columnExpressions/index.d.ts +6 -3
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +25 -50
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +43 -67
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +39 -0
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +31 -60
- package/dist/columnExpressions/mixins/ListExpr.d.ts +16 -40
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +7 -33
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +6 -31
- package/dist/columnExpressions/mixins/StringExpr.d.ts +7 -32
- package/dist/columnExpressions/mixins/StructExpr.d.ts +16 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +4 -30
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +27 -49
- package/dist/columnExpressions/types.d.ts +1 -0
- package/dist/columnExpressions/utils.d.ts +4 -0
- package/dist/constants.d.ts +11 -0
- package/dist/dataframe/constants.d.ts +3 -0
- package/dist/dataframe/dataframe.d.ts +28 -11
- package/dist/dataframe/grouped/grouped.d.ts +2 -3
- package/dist/dataframe/types.d.ts +65 -1
- package/dist/dataframe/utils.d.ts +11 -3
- package/dist/datatypes/DataType.d.ts +2 -1
- package/dist/datatypes/index.d.ts +4 -3
- package/dist/datatypes/types.d.ts +42 -41
- package/dist/exceptions/index.d.ts +2 -0
- package/dist/exceptions/utils.d.ts +1 -0
- package/dist/functions/concat.d.ts +1 -2
- package/dist/functions/index.d.ts +3 -1
- package/dist/functions/read_csv.d.ts +8 -0
- package/dist/functions/read_json.d.ts +10 -0
- package/dist/index.js +6 -1
- package/dist/types.d.ts +34 -6
- package/dist/utils/array.d.ts +217 -0
- package/dist/utils/binary.d.ts +3 -0
- package/dist/utils/csv.d.ts +77 -0
- package/dist/utils/date.d.ts +21 -35
- package/dist/utils/guards.d.ts +11 -12
- package/dist/utils/index.d.ts +5 -2
- package/dist/utils/json.d.ts +120 -2
- package/dist/utils/list.d.ts +196 -2
- package/dist/utils/number.d.ts +47 -29
- package/dist/utils/object.d.ts +26 -0
- package/dist/utils/string.d.ts +7 -4
- package/package.json +6 -2
- package/dist/api.js +0 -18
- package/dist/bundle.min.js +0 -1
- package/dist/columnExpressions/ColumnExpr.js +0 -23
- package/dist/columnExpressions/ExprBase.js +0 -133
- package/dist/columnExpressions/constants.js +0 -5
- package/dist/columnExpressions/functions/all.js +0 -11
- package/dist/columnExpressions/functions/coalesce.js +0 -40
- package/dist/columnExpressions/functions/exclude.js +0 -13
- package/dist/columnExpressions/functions/lit.js +0 -22
- package/dist/columnExpressions/functions/when.js +0 -81
- package/dist/columnExpressions/index.js +0 -81
- package/dist/columnExpressions/mixins/AggregationExpr.js +0 -172
- package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -143
- package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -389
- package/dist/columnExpressions/mixins/ListExpr.js +0 -248
- package/dist/columnExpressions/mixins/LogicalExpr.js +0 -54
- package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -35
- package/dist/columnExpressions/mixins/StringExpr.js +0 -249
- package/dist/columnExpressions/mixins/TemporalExpr.js +0 -127
- package/dist/columnExpressions/mixins/WindowExpr.js +0 -281
- package/dist/columnExpressions/types.js +0 -2
- package/dist/dataframe/constants.js +0 -4
- package/dist/dataframe/dataframe.js +0 -749
- package/dist/dataframe/grouped/grouped.js +0 -113
- package/dist/dataframe/index.js +0 -20
- package/dist/dataframe/types.js +0 -2
- package/dist/dataframe/utils.js +0 -215
- package/dist/datatypes/DataType.js +0 -47
- package/dist/datatypes/index.js +0 -46
- package/dist/datatypes/types/Binary.d.ts +0 -9
- package/dist/datatypes/types/Binary.js +0 -18
- package/dist/datatypes/types/Boolean.d.ts +0 -9
- package/dist/datatypes/types/Boolean.js +0 -19
- package/dist/datatypes/types/Date.d.ts +0 -8
- package/dist/datatypes/types/Date.js +0 -21
- package/dist/datatypes/types/Datetime.d.ts +0 -8
- package/dist/datatypes/types/Datetime.js +0 -17
- package/dist/datatypes/types/Decimal.d.ts +0 -10
- package/dist/datatypes/types/Decimal.js +0 -28
- package/dist/datatypes/types/Duration.d.ts +0 -8
- package/dist/datatypes/types/Duration.js +0 -17
- package/dist/datatypes/types/Float32.d.ts +0 -8
- package/dist/datatypes/types/Float32.js +0 -17
- package/dist/datatypes/types/Float64.d.ts +0 -8
- package/dist/datatypes/types/Float64.js +0 -17
- package/dist/datatypes/types/Int16.d.ts +0 -8
- package/dist/datatypes/types/Int16.js +0 -17
- package/dist/datatypes/types/Int32.d.ts +0 -8
- package/dist/datatypes/types/Int32.js +0 -17
- package/dist/datatypes/types/Int64.d.ts +0 -8
- package/dist/datatypes/types/Int64.js +0 -17
- package/dist/datatypes/types/Int8.d.ts +0 -8
- package/dist/datatypes/types/Int8.js +0 -17
- package/dist/datatypes/types/List.d.ts +0 -10
- package/dist/datatypes/types/List.js +0 -31
- package/dist/datatypes/types/Null.d.ts +0 -9
- package/dist/datatypes/types/Null.js +0 -17
- package/dist/datatypes/types/Object.d.ts +0 -9
- package/dist/datatypes/types/Object.js +0 -17
- package/dist/datatypes/types/Struct.d.ts +0 -14
- package/dist/datatypes/types/Struct.js +0 -39
- package/dist/datatypes/types/Time.d.ts +0 -8
- package/dist/datatypes/types/Time.js +0 -29
- package/dist/datatypes/types/UInt16.d.ts +0 -8
- package/dist/datatypes/types/UInt16.js +0 -17
- package/dist/datatypes/types/UInt32.d.ts +0 -8
- package/dist/datatypes/types/UInt32.js +0 -17
- package/dist/datatypes/types/UInt64.d.ts +0 -8
- package/dist/datatypes/types/UInt64.js +0 -17
- package/dist/datatypes/types/UInt8.d.ts +0 -8
- package/dist/datatypes/types/UInt8.js +0 -17
- package/dist/datatypes/types/Utf8.d.ts +0 -10
- package/dist/datatypes/types/Utf8.js +0 -20
- package/dist/datatypes/types.js +0 -286
- package/dist/exceptions/index.js +0 -43
- package/dist/exceptions/utils.js +0 -9
- package/dist/functions/concat.js +0 -248
- package/dist/functions/index.js +0 -17
- package/dist/types.js +0 -2
- package/dist/utils/boolean.d.ts +0 -1
- package/dist/utils/boolean.js +0 -18
- package/dist/utils/date.js +0 -349
- package/dist/utils/guards.js +0 -143
- package/dist/utils/index.js +0 -21
- package/dist/utils/json.js +0 -33
- package/dist/utils/list.js +0 -128
- package/dist/utils/number.js +0 -223
- package/dist/utils/string.js +0 -120
|
@@ -1,42 +1,59 @@
|
|
|
1
1
|
import { GroupedData } from "./grouped/grouped";
|
|
2
|
-
import type { IExpr, ColumnDict, DataFrameColumns, ConcatOptions, ConcatItem, HorizontalConcatOptions, RowRecord } from "../types";
|
|
3
|
-
import type { LimitOptions, SortOptions, PivotOptions, JoinOptions, UnpivotOptions } from "./types";
|
|
4
|
-
import { DataType } from "../datatypes";
|
|
2
|
+
import type { IExpr, ColumnData, ColumnDict, DataFrameColumns, ConcatOptions, ConcatItem, HorizontalConcatOptions, RowRecord, DataFrameSchema, RegisteredDataType, ExplodeOptions, IntoExpr, FillNullOptions } from "../types";
|
|
3
|
+
import type { LimitOptions, SortOptions, PivotOptions, JoinOptions, UnpivotOptions, TransposeOptions, WriteJSONOptions, WriteCSVOptions } from "./types";
|
|
5
4
|
export declare class DataFrame<T extends RowRecord = any> {
|
|
6
5
|
_columns: DataFrameColumns<T>;
|
|
7
6
|
private _height;
|
|
8
7
|
private _schema;
|
|
9
|
-
|
|
8
|
+
static _createDirect<U extends RowRecord = any>(columns: ColumnDict, schema: DataFrameSchema, height: number): DataFrame<U>;
|
|
9
|
+
constructor(data: T[] | ColumnDict, schema?: DataFrameSchema, height?: number);
|
|
10
10
|
private inferSchema;
|
|
11
11
|
private applySchema;
|
|
12
|
-
getSchema(): Record<string, DataType>;
|
|
13
|
-
to_dicts(): T[];
|
|
14
|
-
to_dict(): DataFrameColumns<T>;
|
|
15
12
|
get columns(): string[];
|
|
16
13
|
concat<U extends RowRecord = any>(items: ConcatItem | ConcatItem[], options?: ConcatOptions): DataFrame<U>;
|
|
17
14
|
drop<K extends keyof T>(...args: (K | K[])[]): DataFrame<Omit<T, K>>;
|
|
18
|
-
|
|
15
|
+
drop_nulls(subset?: string | string[]): DataFrame<T>;
|
|
16
|
+
get dtypes(): RegisteredDataType[];
|
|
17
|
+
explode(columns: IntoExpr | IntoExpr[], options?: ExplodeOptions): DataFrame<any>;
|
|
18
|
+
fill_null(options?: FillNullOptions): DataFrame<T>;
|
|
19
19
|
filter(...exprs: (IExpr | ((row: T) => any))[]): DataFrame<T>;
|
|
20
|
+
get_schema(): DataFrameSchema;
|
|
20
21
|
groupby<K extends keyof T>(keys: K | K[]): GroupedData<T, K>;
|
|
21
22
|
head(n?: number): DataFrame<T>;
|
|
22
23
|
get height(): number;
|
|
23
24
|
hstack<U extends RowRecord = any>(other: ConcatItem | ConcatItem[], options?: HorizontalConcatOptions): DataFrame<U>;
|
|
25
|
+
insert_column(index: number, name: string, expr: IntoExpr): DataFrame<any>;
|
|
26
|
+
item(row?: number, column?: number | string): any;
|
|
27
|
+
iter_columns(): Generator<ColumnData>;
|
|
28
|
+
iter_rows({ named }?: {
|
|
29
|
+
named?: boolean;
|
|
30
|
+
}): Generator<any[] | Record<string, any>>;
|
|
24
31
|
join<U extends RowRecord = any, R extends RowRecord = any>(config: JoinOptions<T, U>): DataFrame<R>;
|
|
25
|
-
limit(n: number,
|
|
32
|
+
limit(n: number, { offset, from }?: LimitOptions): DataFrame<T>;
|
|
26
33
|
pivot<U extends RowRecord = any>(config: PivotOptions<T>): DataFrame<U>;
|
|
27
34
|
rename(mapping?: Partial<Record<keyof T, string>>): DataFrame<any>;
|
|
28
35
|
reverse(): DataFrame<T>;
|
|
29
|
-
get schema():
|
|
36
|
+
get schema(): DataFrameSchema;
|
|
30
37
|
select<U extends RowRecord = any>(...args: (string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]): DataFrame<U>;
|
|
31
38
|
get shape(): [number, number];
|
|
32
39
|
slice(start: number, end?: number): DataFrame<T>;
|
|
33
40
|
sort(config?: SortOptions<T>): DataFrame<T>;
|
|
34
41
|
tail(n?: number): DataFrame<T>;
|
|
35
|
-
|
|
42
|
+
to_dict(): DataFrameColumns<T>;
|
|
43
|
+
to_dicts(): T[];
|
|
44
|
+
to_array<K extends keyof T>(nameOrExpr: K | IExpr): any[];
|
|
45
|
+
transpose({ include_header: includeHeader, header_name: headerName, column_names: colNamesOpt }?: TransposeOptions): DataFrame<any>;
|
|
36
46
|
unique<K extends keyof T>(columns?: K | K[]): DataFrame<T>;
|
|
37
47
|
unpivot<U extends RowRecord = any>(config: UnpivotOptions<T>): DataFrame<U>;
|
|
38
48
|
vstack<U extends RowRecord = any>(other: ConcatItem | ConcatItem[]): DataFrame<U>;
|
|
39
49
|
get width(): number;
|
|
40
50
|
private _normalizeArgs;
|
|
41
51
|
with_columns(...args: (string | IExpr | Record<string, any> | (string | IExpr | Record<string, any>)[])[]): DataFrame<any>;
|
|
52
|
+
with_row_index(name?: string, offset?: number): DataFrame<any>;
|
|
53
|
+
write_json(file?: string | {
|
|
54
|
+
write: (str: string) => void;
|
|
55
|
+
}, { format, replacerOptions }?: WriteJSONOptions): string;
|
|
56
|
+
write_csv(file?: string | {
|
|
57
|
+
write: (str: string) => void;
|
|
58
|
+
}, options?: WriteCSVOptions): string;
|
|
42
59
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DataFrame } from "../dataframe";
|
|
2
2
|
import type { GroupMap } from "../types";
|
|
3
|
-
import {
|
|
4
|
-
import type { IExpr, ColumnDict, RowRecord } from "../../types";
|
|
3
|
+
import type { IExpr, ColumnDict, RowRecord, DataFrameSchema } from "../../types";
|
|
5
4
|
export declare class GroupedData<T, K extends keyof T> {
|
|
6
5
|
private groups;
|
|
7
6
|
private keys;
|
|
@@ -9,7 +8,7 @@ export declare class GroupedData<T, K extends keyof T> {
|
|
|
9
8
|
private parentColumns;
|
|
10
9
|
private parentHeight;
|
|
11
10
|
private parentSchema;
|
|
12
|
-
constructor(groups: GroupMap, keys: K[], allKeys: (keyof T)[], parentColumns: ColumnDict, parentHeight: number, parentSchema:
|
|
11
|
+
constructor(groups: GroupMap, keys: K[], allKeys: (keyof T)[], parentColumns: ColumnDict, parentHeight: number, parentSchema: DataFrameSchema);
|
|
13
12
|
to_dataframe<U extends RowRecord = any>(): DataFrame<U>;
|
|
14
13
|
agg<U extends RowRecord = any>(...exprs: (IExpr | any)[]): DataFrame<U>;
|
|
15
14
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { IExpr, AggFn, RowRecord } from "../types";
|
|
1
|
+
import type { IExpr, AggFn, RowRecord, DataFrameSchema, JSONFormat } from "../types";
|
|
2
2
|
import type { DataFrame } from "./dataframe";
|
|
3
|
+
import type { JSONParseOptions, SafeJsonReplacerOptions, NDJSONParseOptions } from "../utils";
|
|
4
|
+
export type { JSONParseOptions, SafeJsonReplacerOptions, NDJSONParseOptions };
|
|
3
5
|
export type JoinType = "inner" | "left" | "outer" | "right";
|
|
4
6
|
export type LimitPosition = "start" | "end";
|
|
5
7
|
export type GroupMap = Map<string, number[]>;
|
|
@@ -31,3 +33,65 @@ export interface UnpivotOptions<T> {
|
|
|
31
33
|
varName?: string;
|
|
32
34
|
valueName?: string;
|
|
33
35
|
}
|
|
36
|
+
export interface TransposeOptions {
|
|
37
|
+
include_header?: boolean;
|
|
38
|
+
header_name?: string;
|
|
39
|
+
column_names?: string | Iterable<string>;
|
|
40
|
+
}
|
|
41
|
+
export interface ReadJSONOptions extends JSONParseOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Optional explicit schema mapping column names to their registered data types.
|
|
44
|
+
*/
|
|
45
|
+
schema?: DataFrameSchema;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The `replacer` argument type extracted directly from the overloads of the built-in `JSON.stringify`.
|
|
49
|
+
* Hover or Go-to-Definition on `JSON.stringify` below to inspect the standard library signatures.
|
|
50
|
+
*/
|
|
51
|
+
export type JSONStringifyReplacer = typeof JSON.stringify extends {
|
|
52
|
+
(value: any, replacer?: infer R1, space?: any): string;
|
|
53
|
+
(value: any, replacer?: infer R2, space?: any): string;
|
|
54
|
+
} ? R1 | R2 : never;
|
|
55
|
+
export interface WriteJSONOptions {
|
|
56
|
+
/**
|
|
57
|
+
* The format of the JSON output.
|
|
58
|
+
* @default "json"
|
|
59
|
+
*/
|
|
60
|
+
format?: JSONFormat;
|
|
61
|
+
/**
|
|
62
|
+
* Options for the safe JSON replacer.
|
|
63
|
+
*/
|
|
64
|
+
replacerOptions?: SafeJsonReplacerOptions;
|
|
65
|
+
}
|
|
66
|
+
export type { WriteCSVOptions } from "../utils";
|
|
67
|
+
export interface ReadCSVOptions {
|
|
68
|
+
/**
|
|
69
|
+
* Whether the CSV has a header row.
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
hasHeader?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Character that separates fields.
|
|
75
|
+
* @default ","
|
|
76
|
+
*/
|
|
77
|
+
separator?: string;
|
|
78
|
+
/**
|
|
79
|
+
* The character used for quoting fields.
|
|
80
|
+
* @default '"'
|
|
81
|
+
*/
|
|
82
|
+
quoteChar?: string;
|
|
83
|
+
/**
|
|
84
|
+
* String representations of null values.
|
|
85
|
+
* @default ["", "NA", "null", "NaN"]
|
|
86
|
+
*/
|
|
87
|
+
nullValues?: string[];
|
|
88
|
+
/**
|
|
89
|
+
* Optional explicit schema mapping column names to their registered data types.
|
|
90
|
+
*/
|
|
91
|
+
schema?: DataFrameSchema;
|
|
92
|
+
/**
|
|
93
|
+
* Try to infer types from values if no schema is provided.
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
inferSchema?: boolean;
|
|
97
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { IExpr, ColumnData, ColumnDict } from "../types";
|
|
2
|
-
import { DataType } from "../datatypes";
|
|
1
|
+
import type { IExpr, ColumnData, ColumnDict, RegisteredDataType } from "../types";
|
|
3
2
|
export declare function resolveWindowExpr(expr: IExpr, columns: ColumnDict, height: number): ColumnData;
|
|
4
3
|
export declare function rowsToColumns(rows: any[]): {
|
|
5
4
|
columns: ColumnDict;
|
|
@@ -7,5 +6,14 @@ export declare function rowsToColumns(rows: any[]): {
|
|
|
7
6
|
};
|
|
8
7
|
export declare function columnsToRows(columns: ColumnDict, height: number): any[];
|
|
9
8
|
export declare function getRowFromColumns(columns: ColumnDict, idx: number, keys: string[]): any;
|
|
10
|
-
export declare function inferColumnType(col: ColumnData):
|
|
9
|
+
export declare function inferColumnType(col: ColumnData): RegisteredDataType;
|
|
11
10
|
export declare function gatherColumnsByIndices(columns: ColumnDict, indices: number[]): ColumnDict;
|
|
11
|
+
/**
|
|
12
|
+
* Computes a hash string for a row at the given index, using one or more column keys.
|
|
13
|
+
* Includes a single-key fast path to avoid array allocation and join overhead.
|
|
14
|
+
*/
|
|
15
|
+
export declare function computeRowHash(columns: ColumnDict, keys: string[], rowIndex: number): string;
|
|
16
|
+
export declare function coerceColumn(col: ColumnData, type: RegisteredDataType, height: number): ColumnData;
|
|
17
|
+
export declare function writeStringToFileOrStream(file: string | {
|
|
18
|
+
write: (str: string) => void;
|
|
19
|
+
} | undefined, content: string): void;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export declare abstract class DataType<T = any> {
|
|
2
2
|
abstract readonly name: string;
|
|
3
|
-
abstract coerce(val:
|
|
3
|
+
abstract coerce(val: unknown): T;
|
|
4
4
|
abstract equals(other: DataType): boolean;
|
|
5
5
|
abstract allocate(size: number): ArrayLike<T>;
|
|
6
|
+
matches(selector: any): boolean;
|
|
6
7
|
get isNumeric(): boolean;
|
|
7
8
|
get isInteger(): boolean;
|
|
8
9
|
get isFloat(): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataType as BaseDataType } from "./DataType";
|
|
2
|
-
import { DecimalType } from "./types";
|
|
2
|
+
import { DecimalType, BooleanDataType as Boolean, DateDataType as Date, ObjectDataType as Object, ArrayDataType as Array } from "./types";
|
|
3
3
|
export { BaseDataType as DataType };
|
|
4
4
|
export declare const DataTypeRegistry: {
|
|
5
5
|
Int8: import("./types").Int8Type;
|
|
@@ -22,8 +22,9 @@ export declare const DataTypeRegistry: {
|
|
|
22
22
|
Duration: import("./types").DurationType;
|
|
23
23
|
Object: import("./types").ObjectType;
|
|
24
24
|
Null: import("./types").NullType;
|
|
25
|
-
|
|
26
|
-
Struct: <TFields extends import("..").RowRecord>(fields: { [K in keyof TFields]: BaseDataType<TFields[K]>; }) => import("./types").StructType<TFields>;
|
|
25
|
+
Array: <TInner>(inner: import("./types").RegisteredDataType & BaseDataType<TInner>) => import("./types").ArrayType<TInner>;
|
|
26
|
+
Struct: <TFields extends import("..").RowRecord>(fields: { [K in keyof TFields]: import("./types").RegisteredDataType & BaseDataType<TFields[K]>; }) => import("./types").StructType<TFields>;
|
|
27
27
|
};
|
|
28
|
+
export { Boolean, Date, Object, Array };
|
|
28
29
|
export * from "./types";
|
|
29
30
|
export * from "./DataType";
|
|
@@ -2,70 +2,70 @@ import { DataType, SignedIntegerType, UnsignedIntegerType, FloatDataType, Tempor
|
|
|
2
2
|
import type { RowRecord } from "../types";
|
|
3
3
|
export declare class Int8Type extends SignedIntegerType {
|
|
4
4
|
readonly name = "Int8";
|
|
5
|
-
coerce(val:
|
|
5
|
+
coerce(val: unknown): number | null;
|
|
6
6
|
equals(other: DataType): boolean;
|
|
7
7
|
allocate(size: number): Int8Array;
|
|
8
8
|
}
|
|
9
9
|
export declare const Int8: Int8Type;
|
|
10
10
|
export declare class Int16Type extends SignedIntegerType {
|
|
11
11
|
readonly name = "Int16";
|
|
12
|
-
coerce(val:
|
|
12
|
+
coerce(val: unknown): number | null;
|
|
13
13
|
equals(other: DataType): boolean;
|
|
14
14
|
allocate(size: number): Int16Array;
|
|
15
15
|
}
|
|
16
16
|
export declare const Int16: Int16Type;
|
|
17
17
|
export declare class Int32Type extends SignedIntegerType {
|
|
18
18
|
readonly name = "Int32";
|
|
19
|
-
coerce(val:
|
|
19
|
+
coerce(val: unknown): number | null;
|
|
20
20
|
equals(other: DataType): boolean;
|
|
21
21
|
allocate(size: number): Int32Array;
|
|
22
22
|
}
|
|
23
23
|
export declare const Int32: Int32Type;
|
|
24
24
|
export declare class Int64Type extends SignedIntegerType<bigint | null> {
|
|
25
25
|
readonly name = "Int64";
|
|
26
|
-
coerce(val:
|
|
26
|
+
coerce(val: unknown): bigint | null;
|
|
27
27
|
equals(other: DataType): boolean;
|
|
28
28
|
allocate(size: number): BigInt64Array;
|
|
29
29
|
}
|
|
30
30
|
export declare const Int64: Int64Type;
|
|
31
31
|
export declare class UInt8Type extends UnsignedIntegerType {
|
|
32
32
|
readonly name = "UInt8";
|
|
33
|
-
coerce(val:
|
|
33
|
+
coerce(val: unknown): number | null;
|
|
34
34
|
equals(other: DataType): boolean;
|
|
35
35
|
allocate(size: number): Uint8Array;
|
|
36
36
|
}
|
|
37
37
|
export declare const UInt8: UInt8Type;
|
|
38
38
|
export declare class UInt16Type extends UnsignedIntegerType {
|
|
39
39
|
readonly name = "UInt16";
|
|
40
|
-
coerce(val:
|
|
40
|
+
coerce(val: unknown): number | null;
|
|
41
41
|
equals(other: DataType): boolean;
|
|
42
42
|
allocate(size: number): Uint16Array;
|
|
43
43
|
}
|
|
44
44
|
export declare const UInt16: UInt16Type;
|
|
45
45
|
export declare class UInt32Type extends UnsignedIntegerType {
|
|
46
46
|
readonly name = "UInt32";
|
|
47
|
-
coerce(val:
|
|
47
|
+
coerce(val: unknown): number | null;
|
|
48
48
|
equals(other: DataType): boolean;
|
|
49
49
|
allocate(size: number): Uint32Array;
|
|
50
50
|
}
|
|
51
51
|
export declare const UInt32: UInt32Type;
|
|
52
52
|
export declare class UInt64Type extends UnsignedIntegerType<bigint | null> {
|
|
53
53
|
readonly name = "UInt64";
|
|
54
|
-
coerce(val:
|
|
54
|
+
coerce(val: unknown): bigint | null;
|
|
55
55
|
equals(other: DataType): boolean;
|
|
56
56
|
allocate(size: number): BigUint64Array;
|
|
57
57
|
}
|
|
58
58
|
export declare const UInt64: UInt64Type;
|
|
59
59
|
export declare class Float32Type extends FloatDataType {
|
|
60
60
|
readonly name = "Float32";
|
|
61
|
-
coerce(val:
|
|
61
|
+
coerce(val: unknown): number | null;
|
|
62
62
|
equals(other: DataType): boolean;
|
|
63
63
|
allocate(size: number): Float32Array;
|
|
64
64
|
}
|
|
65
65
|
export declare const Float32: Float32Type;
|
|
66
66
|
export declare class Float64Type extends FloatDataType {
|
|
67
67
|
readonly name = "Float64";
|
|
68
|
-
coerce(val:
|
|
68
|
+
coerce(val: unknown): number | null;
|
|
69
69
|
equals(other: DataType): boolean;
|
|
70
70
|
allocate(size: number): Float64Array;
|
|
71
71
|
}
|
|
@@ -75,39 +75,39 @@ export declare class DecimalType extends NumericDataType {
|
|
|
75
75
|
readonly scale?: number | undefined;
|
|
76
76
|
readonly name: string;
|
|
77
77
|
constructor(precision?: number | undefined, scale?: number | undefined);
|
|
78
|
-
coerce(val:
|
|
78
|
+
coerce(val: unknown): number | null;
|
|
79
79
|
equals(other: DataType): boolean;
|
|
80
80
|
allocate(size: number): (number | null)[];
|
|
81
81
|
}
|
|
82
|
-
export declare class BooleanType extends DataType {
|
|
82
|
+
export declare class BooleanType extends DataType<boolean | null> {
|
|
83
83
|
readonly name = "Boolean";
|
|
84
84
|
get isBoolean(): boolean;
|
|
85
|
-
coerce(val:
|
|
85
|
+
coerce(val: unknown): boolean | null;
|
|
86
86
|
equals(other: DataType): boolean;
|
|
87
87
|
allocate(size: number): (boolean | null)[];
|
|
88
88
|
}
|
|
89
|
-
export declare const
|
|
90
|
-
export declare class Utf8Type extends DataType {
|
|
89
|
+
export declare const BooleanDataType: BooleanType;
|
|
90
|
+
export declare class Utf8Type extends DataType<string | null> {
|
|
91
91
|
readonly name = "Utf8";
|
|
92
92
|
get isString(): boolean;
|
|
93
93
|
get isUtf8(): boolean;
|
|
94
|
-
coerce(val:
|
|
94
|
+
coerce(val: unknown): string | null;
|
|
95
95
|
equals(other: DataType): boolean;
|
|
96
96
|
allocate(size: number): (string | null)[];
|
|
97
97
|
}
|
|
98
98
|
export declare const Utf8: Utf8Type;
|
|
99
|
-
export declare class BinaryType extends DataType {
|
|
99
|
+
export declare class BinaryType extends DataType<Uint8Array | null> {
|
|
100
100
|
readonly name = "Binary";
|
|
101
101
|
get isBinary(): boolean;
|
|
102
|
-
coerce(val:
|
|
102
|
+
coerce(val: unknown): Uint8Array | null;
|
|
103
103
|
equals(other: DataType): boolean;
|
|
104
104
|
allocate(size: number): (Uint8Array | null)[];
|
|
105
105
|
}
|
|
106
106
|
export declare const Binary: BinaryType;
|
|
107
|
-
export declare class NullType extends DataType {
|
|
107
|
+
export declare class NullType extends DataType<null> {
|
|
108
108
|
readonly name = "Null";
|
|
109
109
|
get isNull(): boolean;
|
|
110
|
-
coerce(_val:
|
|
110
|
+
coerce(_val: unknown): null;
|
|
111
111
|
equals(other: DataType): boolean;
|
|
112
112
|
allocate(size: number): null[];
|
|
113
113
|
}
|
|
@@ -115,58 +115,59 @@ export declare const Null: NullType;
|
|
|
115
115
|
export declare class ObjectType extends DataType {
|
|
116
116
|
readonly name = "Object";
|
|
117
117
|
get isObject(): boolean;
|
|
118
|
-
coerce(val:
|
|
118
|
+
coerce(val: unknown): any;
|
|
119
119
|
equals(other: DataType): boolean;
|
|
120
120
|
allocate(size: number): any[];
|
|
121
121
|
}
|
|
122
|
-
export declare const
|
|
123
|
-
export declare class DateType extends TemporalDataType {
|
|
122
|
+
export declare const ObjectDataType: ObjectType;
|
|
123
|
+
export declare class DateType extends TemporalDataType<Date | null> {
|
|
124
124
|
readonly name = "Date";
|
|
125
|
-
coerce(val:
|
|
125
|
+
coerce(val: unknown): Date | null;
|
|
126
126
|
equals(other: DataType): boolean;
|
|
127
127
|
allocate(size: number): (Date | null)[];
|
|
128
128
|
}
|
|
129
|
-
export declare const
|
|
130
|
-
export declare class DatetimeType extends TemporalDataType {
|
|
129
|
+
export declare const DateDataType: DateType;
|
|
130
|
+
export declare class DatetimeType extends TemporalDataType<Date | null> {
|
|
131
131
|
readonly name = "Datetime";
|
|
132
|
-
coerce(val:
|
|
132
|
+
coerce(val: unknown): Date | null;
|
|
133
133
|
equals(other: DataType): boolean;
|
|
134
134
|
allocate(size: number): (Date | null)[];
|
|
135
135
|
}
|
|
136
136
|
export declare const Datetime: DatetimeType;
|
|
137
|
-
export declare class TimeType extends TemporalDataType {
|
|
137
|
+
export declare class TimeType extends TemporalDataType<string | null> {
|
|
138
138
|
readonly name = "Time";
|
|
139
|
-
coerce(val:
|
|
139
|
+
coerce(val: unknown): string | null;
|
|
140
140
|
equals(other: DataType): boolean;
|
|
141
141
|
allocate(size: number): (string | null)[];
|
|
142
142
|
}
|
|
143
143
|
export declare const Time: TimeType;
|
|
144
|
-
export declare class DurationType extends TemporalDataType {
|
|
144
|
+
export declare class DurationType extends TemporalDataType<number | null> {
|
|
145
145
|
readonly name = "Duration";
|
|
146
|
-
coerce(val:
|
|
146
|
+
coerce(val: unknown): number | null;
|
|
147
147
|
equals(other: DataType): boolean;
|
|
148
148
|
allocate(size: number): (number | null)[];
|
|
149
149
|
}
|
|
150
150
|
export declare const Duration: DurationType;
|
|
151
|
-
export declare class
|
|
152
|
-
readonly innerType: DataType<TInner>;
|
|
153
|
-
readonly name = "
|
|
154
|
-
constructor(innerType: DataType<TInner>);
|
|
155
|
-
coerce(val:
|
|
151
|
+
export declare class ArrayType<TInner = any> extends NestedDataType<TInner[] | null> {
|
|
152
|
+
readonly innerType: RegisteredDataType & DataType<TInner>;
|
|
153
|
+
readonly name = "Array";
|
|
154
|
+
constructor(innerType: RegisteredDataType & DataType<TInner>);
|
|
155
|
+
coerce(val: unknown): TInner[] | null;
|
|
156
156
|
equals(other: DataType): boolean;
|
|
157
157
|
allocate(size: number): (TInner[] | null)[];
|
|
158
158
|
}
|
|
159
|
-
export declare const
|
|
159
|
+
export declare const ArrayDataType: <TInner>(inner: RegisteredDataType & DataType<TInner>) => ArrayType<TInner>;
|
|
160
160
|
export declare class StructType<TFields extends RowRecord = any> extends NestedDataType<TFields | null> {
|
|
161
161
|
readonly fields: {
|
|
162
|
-
[K in keyof TFields]: DataType<TFields[K]>;
|
|
162
|
+
[K in keyof TFields]: RegisteredDataType & DataType<TFields[K]>;
|
|
163
163
|
};
|
|
164
164
|
readonly name = "Struct";
|
|
165
165
|
constructor(fields: {
|
|
166
|
-
[K in keyof TFields]: DataType<TFields[K]>;
|
|
166
|
+
[K in keyof TFields]: RegisteredDataType & DataType<TFields[K]>;
|
|
167
167
|
});
|
|
168
|
-
coerce(val:
|
|
168
|
+
coerce(val: unknown): TFields | null;
|
|
169
169
|
equals(other: DataType): boolean;
|
|
170
170
|
allocate(size: number): (TFields | null)[];
|
|
171
171
|
}
|
|
172
|
-
export declare const Struct: <TFields extends RowRecord>(fields: { [K in keyof TFields]: DataType<TFields[K]>; }) => StructType<TFields>;
|
|
172
|
+
export declare const Struct: <TFields extends RowRecord>(fields: { [K in keyof TFields]: RegisteredDataType & DataType<TFields[K]>; }) => StructType<TFields>;
|
|
173
|
+
export type RegisteredDataType = Int8Type | Int16Type | Int32Type | Int64Type | UInt8Type | UInt16Type | UInt32Type | UInt64Type | Float32Type | Float64Type | DecimalType | BooleanType | Utf8Type | BinaryType | NullType | ObjectType | DateType | DatetimeType | TimeType | DurationType | ArrayType<any> | StructType<any>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { DataFrame } from "../dataframe/dataframe";
|
|
2
2
|
import type { ConcatOptions, ConcatItem, RowRecord } from "../types";
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function concat<U extends RowRecord = any>(rawItems: ConcatItem | ConcatItem[], options?: ConcatOptions): DataFrame<U>;
|
|
3
|
+
export declare function concat<U extends RowRecord = any>(rawItems: ConcatItem | ConcatItem[], { how, horizontal }?: ConcatOptions): DataFrame<U>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataFrame } from "../dataframe/dataframe";
|
|
2
|
+
import type { ReadCSVOptions } from "../dataframe/types";
|
|
3
|
+
import type { RowRecord } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Reads a CSV string and constructs a DataFrame.
|
|
6
|
+
* Automatically infers column data types unless an explicit schema is provided.
|
|
7
|
+
*/
|
|
8
|
+
export declare function read_csv<T extends RowRecord = any>(content: string, options?: ReadCSVOptions): DataFrame<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DataFrame } from "../dataframe/dataframe";
|
|
2
|
+
import type { ReadJSONOptions } from "../dataframe/types";
|
|
3
|
+
/**
|
|
4
|
+
* Parses JSON content (JSON or NDJSON) and loads it into a new DataFrame.
|
|
5
|
+
*
|
|
6
|
+
* @param content The JSON or NDJSON content string.
|
|
7
|
+
* @param options Parse and configuration options.
|
|
8
|
+
* @returns A new DataFrame instance populated with the parsed records.
|
|
9
|
+
*/
|
|
10
|
+
export declare function read_json(content: string, { format, trimBeforeParse, schema, ...parseOpts }?: ReadJSONOptions): DataFrame<any>;
|