df-script 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/api.d.ts +3 -1
- package/dist/assets/index-DBhGK6Tp.css +1 -0
- package/dist/assets/index-DEJEV_tU.js +195 -0
- package/dist/columnExpressions/ColumnExpr.d.ts +12 -5
- package/dist/columnExpressions/ExprBase.d.ts +27 -12
- package/dist/columnExpressions/constants.d.ts +2 -0
- package/dist/columnExpressions/functions/all.d.ts +23 -0
- package/dist/columnExpressions/functions/coalesce.d.ts +29 -0
- package/dist/columnExpressions/functions/duration.d.ts +33 -0
- package/dist/columnExpressions/functions/element.d.ts +25 -0
- package/dist/columnExpressions/functions/exclude.d.ts +24 -0
- package/dist/columnExpressions/functions/implode.d.ts +28 -0
- package/dist/columnExpressions/functions/lit.d.ts +27 -0
- package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
- package/dist/columnExpressions/functions/struct.d.ts +31 -0
- package/dist/columnExpressions/functions/when.d.ts +36 -6
- package/dist/columnExpressions/index.d.ts +2 -0
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +334 -0
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +609 -0
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +533 -5
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +656 -3
- package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +588 -11
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
- package/dist/columnExpressions/types.d.ts +1 -0
- package/dist/columnExpressions/utils.d.ts +10 -0
- package/dist/constants.d.ts +15 -3
- package/dist/dataframe/dataframe.d.ts +1073 -3
- package/dist/dataframe/grouped/grouped.d.ts +41 -6
- package/dist/dataframe/types.d.ts +26 -3
- package/dist/dataframe/utils.d.ts +22 -1
- package/dist/datatypes/types.d.ts +51 -1
- package/dist/exceptions/index.d.ts +33 -0
- package/dist/exceptions/utils.d.ts +2 -0
- package/dist/functions/concat.d.ts +50 -0
- package/dist/functions/read_csv.d.ts +9 -0
- package/dist/functions/read_json.d.ts +7 -2
- package/dist/index.html +17 -0
- package/dist/index.js +6 -6
- package/dist/index.mjs +6 -0
- package/dist/types.d.ts +70 -14
- package/dist/utils/array.d.ts +55 -1
- package/dist/utils/csv.d.ts +1 -0
- package/dist/utils/date.d.ts +14 -27
- package/dist/utils/duration.d.ts +5 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/json.d.ts +1 -0
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/string.d.ts +12 -0
- package/package.json +28 -4
- package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
- package/dist/utils/guards.d.ts +0 -13
- package/dist/utils/list.d.ts +0 -217
|
@@ -1,14 +1,49 @@
|
|
|
1
1
|
import { DataFrame } from "../dataframe";
|
|
2
2
|
import type { GroupMap } from "../types";
|
|
3
3
|
import type { IExpr, ColumnDict, RowRecord, DataFrameSchema } from "../../types";
|
|
4
|
+
/**
|
|
5
|
+
* Represents a DataFrame grouped by key columns, supporting aggregation operations.
|
|
6
|
+
* @namespace df
|
|
7
|
+
* @category DataFrame
|
|
8
|
+
* @syntax df.groupby(...).{symbol}(...)
|
|
9
|
+
*/
|
|
4
10
|
export declare class GroupedData<T, K extends keyof T> {
|
|
5
|
-
private
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private
|
|
11
|
+
private _groups;
|
|
12
|
+
private _keys;
|
|
13
|
+
private _allKeys;
|
|
14
|
+
private _parentColumns;
|
|
15
|
+
private _parentHeight;
|
|
16
|
+
private _parentSchema;
|
|
11
17
|
constructor(groups: GroupMap, keys: K[], allKeys: (keyof T)[], parentColumns: ColumnDict, parentHeight: number, parentSchema: DataFrameSchema);
|
|
18
|
+
/**
|
|
19
|
+
* Converts group keys back into a single distinct DataFrame without aggregations.
|
|
20
|
+
* @returns DataFrame
|
|
21
|
+
* @example
|
|
22
|
+
* >>> const df = $df.data({ group: ["A", "A", "B"], val: [1, 2, 3] })
|
|
23
|
+
* >>> df.groupby("group").to_dataframe()
|
|
24
|
+
* shape: (2, 1)
|
|
25
|
+
* ┌───────┐
|
|
26
|
+
* │ group │
|
|
27
|
+
* ├───────┤
|
|
28
|
+
* │ A │
|
|
29
|
+
* │ B │
|
|
30
|
+
* └───────┘
|
|
31
|
+
*/
|
|
12
32
|
to_dataframe<U extends RowRecord = any>(): DataFrame<U>;
|
|
33
|
+
/**
|
|
34
|
+
* Aggregates grouped partitions using aggregation column expressions.
|
|
35
|
+
* @param exprs One or more aggregation column expressions.
|
|
36
|
+
* @returns DataFrame
|
|
37
|
+
* @example
|
|
38
|
+
* >>> const df = $df.data({ group: ["A", "A", "B"], val: [10, 20, 30] })
|
|
39
|
+
* >>> df.groupby("group").agg($df.col("val").sum().alias("sum_val"))
|
|
40
|
+
* shape: (2, 2)
|
|
41
|
+
* ┌───────┬─────────┐
|
|
42
|
+
* │ group │ sum_val │
|
|
43
|
+
* ├───────┼─────────┤
|
|
44
|
+
* │ A │ 30 │
|
|
45
|
+
* │ B │ 30 │
|
|
46
|
+
* └───────┴─────────┘
|
|
47
|
+
*/
|
|
13
48
|
agg<U extends RowRecord = any>(...exprs: (IExpr | any)[]): DataFrame<U>;
|
|
14
49
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
/** @typefile */
|
|
1
2
|
import type { IExpr, AggFn, RowRecord, DataFrameSchema, JSONFormat } from "../types";
|
|
2
3
|
import type { DataFrame } from "./dataframe";
|
|
3
4
|
import type { JSONParseOptions, SafeJsonReplacerOptions, NDJSONParseOptions } from "../utils";
|
|
4
5
|
export type { JSONParseOptions, SafeJsonReplacerOptions, NDJSONParseOptions };
|
|
5
|
-
export type JoinType = "inner" | "
|
|
6
|
+
export type JoinType = "inner" | "outer" | "left" | "right" | "semi" | "anti" | "cross";
|
|
7
|
+
export type JoinMaintainOrder = "none" | "left" | "right" | "left_right" | "right_left";
|
|
6
8
|
export type LimitPosition = "start" | "end";
|
|
7
9
|
export type GroupMap = Map<string, number[]>;
|
|
8
10
|
export interface LimitOptions {
|
|
@@ -21,11 +23,32 @@ export interface PivotOptions<T> {
|
|
|
21
23
|
values: keyof T;
|
|
22
24
|
agg?: AggFn<any> | string;
|
|
23
25
|
}
|
|
24
|
-
export interface JoinOptions<T, U extends RowRecord = any> {
|
|
26
|
+
export interface JoinOptions<T = any, U extends RowRecord = any> {
|
|
25
27
|
other: DataFrame<U>;
|
|
26
|
-
on
|
|
28
|
+
on?: (keyof T & keyof U) | (keyof T & keyof U)[];
|
|
29
|
+
leftOn?: (keyof T) | (keyof T)[];
|
|
30
|
+
rightOn?: (keyof U) | (keyof U)[];
|
|
27
31
|
how?: JoinType;
|
|
28
32
|
suffixes?: [string, string];
|
|
33
|
+
join_nulls?: boolean;
|
|
34
|
+
coalesce?: boolean;
|
|
35
|
+
maintain_order?: JoinMaintainOrder | boolean;
|
|
36
|
+
}
|
|
37
|
+
export type AsofJoinStrategy = "backward" | "forward" | "nearest";
|
|
38
|
+
export interface AsofJoinOptions<T = any, U extends RowRecord = any> {
|
|
39
|
+
other: DataFrame<U>;
|
|
40
|
+
on?: (keyof T & keyof U);
|
|
41
|
+
leftOn?: (keyof T);
|
|
42
|
+
rightOn?: (keyof U);
|
|
43
|
+
by?: (keyof T & keyof U) | (keyof T & keyof U)[];
|
|
44
|
+
leftBy?: (keyof T) | (keyof T)[];
|
|
45
|
+
rightBy?: (keyof U) | (keyof U)[];
|
|
46
|
+
strategy?: AsofJoinStrategy;
|
|
47
|
+
tolerance?: number | string;
|
|
48
|
+
allow_exact_matches?: boolean;
|
|
49
|
+
suffixes?: [string, string];
|
|
50
|
+
coalesce?: boolean;
|
|
51
|
+
check_sorted?: boolean;
|
|
29
52
|
}
|
|
30
53
|
export interface UnpivotOptions<T> {
|
|
31
54
|
idVars: (keyof T) | (keyof T)[];
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/** @internalfile */
|
|
2
|
+
import type { IExpr, ColumnData, ColumnDict, RegisteredDataType, DataFrameSchema, RowRecord } from "../types";
|
|
3
|
+
import type { JoinOptions, AsofJoinOptions } from "./types";
|
|
4
|
+
import { DataFrame } from "./dataframe";
|
|
2
5
|
export declare function resolveWindowExpr(expr: IExpr, columns: ColumnDict, height: number): ColumnData;
|
|
3
6
|
export declare function rowsToColumns(rows: any[]): {
|
|
4
7
|
columns: ColumnDict;
|
|
@@ -17,3 +20,21 @@ export declare function coerceColumn(col: ColumnData, type: RegisteredDataType,
|
|
|
17
20
|
export declare function writeStringToFileOrStream(file: string | {
|
|
18
21
|
write: (str: string) => void;
|
|
19
22
|
} | undefined, content: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Generic key-alignment engine computing positional row index mappings (leftIndex <-> rightIndex)
|
|
25
|
+
* between two columnar datasets based on key hashing.
|
|
26
|
+
* Reusable for Joins, Set Operations (Intersect/Difference), Upserts, and Alignments.
|
|
27
|
+
*/
|
|
28
|
+
export declare function alignKeyIndices(leftCols: ColumnDict, rightCols: ColumnDict, leftHeight: number, rightHeight: number, leftKeys: string[], rightKeys: string[], options?: Partial<JoinOptions>): {
|
|
29
|
+
leftIndices: number[];
|
|
30
|
+
rightIndices: (number | null)[];
|
|
31
|
+
};
|
|
32
|
+
export declare function alignAsofIndices(leftCols: ColumnDict, rightCols: ColumnDict, leftHeight: number, rightHeight: number, leftOnKey: string, rightOnKey: string, leftByKeys: string[], rightByKeys: string[], options?: AsofJoinOptions): {
|
|
33
|
+
leftIndices: number[];
|
|
34
|
+
rightIndices: (number | null)[];
|
|
35
|
+
};
|
|
36
|
+
export declare function materializeJoinedDataFrame<R extends RowRecord = any>(leftCols: ColumnDict, rightCols: ColumnDict, leftSchema: DataFrameSchema, rightSchema: DataFrameSchema, leftIndices: number[], rightIndices: (number | null)[], leftKeysStr: string[], rightKeysStr: string[], options?: {
|
|
37
|
+
suffixes?: [string, string];
|
|
38
|
+
coalesce?: boolean;
|
|
39
|
+
how?: string;
|
|
40
|
+
}): DataFrame<R>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/** @typefile */
|
|
1
2
|
import { DataType, SignedIntegerType, UnsignedIntegerType, FloatDataType, TemporalDataType, NestedDataType, NumericDataType } from "./DataType";
|
|
2
|
-
import type { RowRecord } from "../types";
|
|
3
|
+
import type { RowRecord, DatetimeTimeUnit } from "../types";
|
|
3
4
|
export declare class Int8Type extends SignedIntegerType {
|
|
4
5
|
readonly name = "Int8";
|
|
5
6
|
coerce(val: unknown): number | null;
|
|
@@ -14,6 +15,10 @@ export declare class Int16Type extends SignedIntegerType {
|
|
|
14
15
|
allocate(size: number): Int16Array;
|
|
15
16
|
}
|
|
16
17
|
export declare const Int16: Int16Type;
|
|
18
|
+
/**
|
|
19
|
+
* 32-bit signed integer type (values from -2,147,483,648 to 2,147,483,647).
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
17
22
|
export declare class Int32Type extends SignedIntegerType {
|
|
18
23
|
readonly name = "Int32";
|
|
19
24
|
coerce(val: unknown): number | null;
|
|
@@ -21,6 +26,10 @@ export declare class Int32Type extends SignedIntegerType {
|
|
|
21
26
|
allocate(size: number): Int32Array;
|
|
22
27
|
}
|
|
23
28
|
export declare const Int32: Int32Type;
|
|
29
|
+
/**
|
|
30
|
+
* 64-bit signed integer type (represented as JavaScript BigInt).
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
24
33
|
export declare class Int64Type extends SignedIntegerType<bigint | null> {
|
|
25
34
|
readonly name = "Int64";
|
|
26
35
|
coerce(val: unknown): bigint | null;
|
|
@@ -63,6 +72,10 @@ export declare class Float32Type extends FloatDataType {
|
|
|
63
72
|
allocate(size: number): Float32Array;
|
|
64
73
|
}
|
|
65
74
|
export declare const Float32: Float32Type;
|
|
75
|
+
/**
|
|
76
|
+
* 64-bit double precision floating point number type.
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
66
79
|
export declare class Float64Type extends FloatDataType {
|
|
67
80
|
readonly name = "Float64";
|
|
68
81
|
coerce(val: unknown): number | null;
|
|
@@ -70,6 +83,12 @@ export declare class Float64Type extends FloatDataType {
|
|
|
70
83
|
allocate(size: number): Float64Array;
|
|
71
84
|
}
|
|
72
85
|
export declare const Float64: Float64Type;
|
|
86
|
+
/**
|
|
87
|
+
* Fixed point decimal type with optional precision and scale arguments.
|
|
88
|
+
*
|
|
89
|
+
* @param precision Precision level (total number of digits)
|
|
90
|
+
* @param scale Scale level (number of decimal place digits)
|
|
91
|
+
*/
|
|
73
92
|
export declare class DecimalType extends NumericDataType {
|
|
74
93
|
readonly precision?: number | undefined;
|
|
75
94
|
readonly scale?: number | undefined;
|
|
@@ -79,6 +98,10 @@ export declare class DecimalType extends NumericDataType {
|
|
|
79
98
|
equals(other: DataType): boolean;
|
|
80
99
|
allocate(size: number): (number | null)[];
|
|
81
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Boolean datatype representing binary values (true or false).
|
|
103
|
+
*
|
|
104
|
+
*/
|
|
82
105
|
export declare class BooleanType extends DataType<boolean | null> {
|
|
83
106
|
readonly name = "Boolean";
|
|
84
107
|
get isBoolean(): boolean;
|
|
@@ -87,6 +110,10 @@ export declare class BooleanType extends DataType<boolean | null> {
|
|
|
87
110
|
allocate(size: number): (boolean | null)[];
|
|
88
111
|
}
|
|
89
112
|
export declare const BooleanDataType: BooleanType;
|
|
113
|
+
/**
|
|
114
|
+
* Unicode UTF-8 string datatype.
|
|
115
|
+
*
|
|
116
|
+
*/
|
|
90
117
|
export declare class Utf8Type extends DataType<string | null> {
|
|
91
118
|
readonly name = "Utf8";
|
|
92
119
|
get isString(): boolean;
|
|
@@ -120,6 +147,10 @@ export declare class ObjectType extends DataType {
|
|
|
120
147
|
allocate(size: number): any[];
|
|
121
148
|
}
|
|
122
149
|
export declare const ObjectDataType: ObjectType;
|
|
150
|
+
/**
|
|
151
|
+
* Calendar date type storing UTC year, month, and day.
|
|
152
|
+
*
|
|
153
|
+
*/
|
|
123
154
|
export declare class DateType extends TemporalDataType<Date | null> {
|
|
124
155
|
readonly name = "Date";
|
|
125
156
|
coerce(val: unknown): Date | null;
|
|
@@ -127,8 +158,15 @@ export declare class DateType extends TemporalDataType<Date | null> {
|
|
|
127
158
|
allocate(size: number): (Date | null)[];
|
|
128
159
|
}
|
|
129
160
|
export declare const DateDataType: DateType;
|
|
161
|
+
/**
|
|
162
|
+
* Date and time type (year, month, day, hour, minute, second, millisecond)
|
|
163
|
+
* with timeUnit precision and optional timezone awareness.
|
|
164
|
+
*/
|
|
130
165
|
export declare class DatetimeType extends TemporalDataType<Date | null> {
|
|
131
166
|
readonly name = "Datetime";
|
|
167
|
+
readonly timeUnit: DatetimeTimeUnit;
|
|
168
|
+
readonly timeZone: string | null;
|
|
169
|
+
constructor(timeUnit?: DatetimeTimeUnit, timeZone?: string | null);
|
|
132
170
|
coerce(val: unknown): Date | null;
|
|
133
171
|
equals(other: DataType): boolean;
|
|
134
172
|
allocate(size: number): (Date | null)[];
|
|
@@ -143,11 +181,18 @@ export declare class TimeType extends TemporalDataType<string | null> {
|
|
|
143
181
|
export declare const Time: TimeType;
|
|
144
182
|
export declare class DurationType extends TemporalDataType<number | null> {
|
|
145
183
|
readonly name = "Duration";
|
|
184
|
+
readonly timeUnit: DatetimeTimeUnit;
|
|
185
|
+
constructor(timeUnit?: DatetimeTimeUnit);
|
|
146
186
|
coerce(val: unknown): number | null;
|
|
147
187
|
equals(other: DataType): boolean;
|
|
148
188
|
allocate(size: number): (number | null)[];
|
|
149
189
|
}
|
|
150
190
|
export declare const Duration: DurationType;
|
|
191
|
+
/**
|
|
192
|
+
* Nested array list datatype wrapping an inner element type.
|
|
193
|
+
*
|
|
194
|
+
* @param innerType The child elements datatype
|
|
195
|
+
*/
|
|
151
196
|
export declare class ArrayType<TInner = any> extends NestedDataType<TInner[] | null> {
|
|
152
197
|
readonly innerType: RegisteredDataType & DataType<TInner>;
|
|
153
198
|
readonly name = "Array";
|
|
@@ -157,6 +202,11 @@ export declare class ArrayType<TInner = any> extends NestedDataType<TInner[] | n
|
|
|
157
202
|
allocate(size: number): (TInner[] | null)[];
|
|
158
203
|
}
|
|
159
204
|
export declare const ArrayDataType: <TInner>(inner: RegisteredDataType & DataType<TInner>) => ArrayType<TInner>;
|
|
205
|
+
/**
|
|
206
|
+
* Keyed struct object datatype wrapping sub-field schemas.
|
|
207
|
+
*
|
|
208
|
+
* @param fields Schema mapping of field names to Datatypes
|
|
209
|
+
*/
|
|
160
210
|
export declare class StructType<TFields extends RowRecord = any> extends NestedDataType<TFields | null> {
|
|
161
211
|
readonly fields: {
|
|
162
212
|
[K in keyof TFields]: RegisteredDataType & DataType<TFields[K]>;
|
|
@@ -1,15 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @namespace Exception
|
|
3
|
+
* @category Exception
|
|
4
|
+
* @syntax throw new {symbol}("message")
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base exception class for all df-script errors.
|
|
8
|
+
*/
|
|
1
9
|
export declare class DFScriptError extends Error {
|
|
2
10
|
constructor(message: string);
|
|
3
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* General error thrown during DataFrame instantiation or execution.
|
|
14
|
+
*/
|
|
4
15
|
export declare class DataFrameError extends DFScriptError {
|
|
5
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Error thrown when a specified column name does not exist in the DataFrame schema.
|
|
19
|
+
*/
|
|
6
20
|
export declare class ColumnNotFoundError extends DataFrameError {
|
|
7
21
|
constructor(columnName: string, message?: string);
|
|
8
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Error thrown when schema definitions, coercions, or data types are invalid.
|
|
25
|
+
*/
|
|
9
26
|
export declare class SchemaError extends DFScriptError {
|
|
10
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Error thrown during expression evaluation or element-wise calculations.
|
|
30
|
+
*/
|
|
11
31
|
export declare class ComputeError extends DFScriptError {
|
|
12
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Error thrown when shape dimensions or column heights mismatch.
|
|
35
|
+
*/
|
|
13
36
|
export declare class ShapeError extends DFScriptError {
|
|
14
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Error thrown when a parameter or argument provided to a function is invalid.
|
|
40
|
+
*/
|
|
41
|
+
export declare class InvalidArgumentError extends DFScriptError {
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Error thrown during file I/O or streaming operations.
|
|
45
|
+
*/
|
|
46
|
+
export declare class IOStreamError extends DFScriptError {
|
|
47
|
+
}
|
|
15
48
|
export * from "./utils";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { ColumnDict } from "../types";
|
|
2
2
|
export declare function assertColumnExists(columnName: string, columns: ColumnDict, context: string, suffix?: string): void;
|
|
3
3
|
export declare function assertHeight(columns: ColumnDict, height?: number): number;
|
|
4
|
+
export declare function assertNotNull<T>(value: T | null | undefined, message?: string): T;
|
|
5
|
+
export declare function assertValidArgument(condition: boolean, message: string): void;
|
|
@@ -1,3 +1,53 @@
|
|
|
1
1
|
import { DataFrame } from "../dataframe/dataframe";
|
|
2
2
|
import type { ConcatOptions, ConcatItem, RowRecord } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Concatenates items vertically, horizontally, or diagonally.
|
|
5
|
+
* @namespace $df
|
|
6
|
+
* @category ColumnExpression
|
|
7
|
+
* @syntax $df.{symbol}(...)
|
|
8
|
+
* @param rawItems Single DataFrame or array of DataFrames/rows to concatenate.
|
|
9
|
+
* @param [options] Configuration options for concatenation layout and strictness.
|
|
10
|
+
* @param [options.how] Layout strategy: `"vertical"` (default, appends rows top-to-bottom), `"horizontal"` (joins unique columns side-by-side), or `"diagonal"` (concatenates mismatched columns with null padding).
|
|
11
|
+
* @param [options.horizontal.strict] When `true` (default), throws an error if row counts mismatch in horizontal concatenation. Set `false` to pad shorter DataFrames with `null`.
|
|
12
|
+
* @returns DataFrame
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // 1. Vertical Concatenation (default):
|
|
16
|
+
* >>> const df1 = $df.data({ a: [1] })
|
|
17
|
+
* >>> const df2 = $df.data({ a: [2] })
|
|
18
|
+
* >>> $df.concat([df1, df2], { how: "vertical" })
|
|
19
|
+
* shape: (2, 1)
|
|
20
|
+
* ┌───┐
|
|
21
|
+
* │ a │
|
|
22
|
+
* ├───┤
|
|
23
|
+
* │ 1 │
|
|
24
|
+
* │ 2 │
|
|
25
|
+
* └───┘
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // 2. Horizontal Concatenation:
|
|
29
|
+
* >>> const df1 = $df.data({ a: [1] })
|
|
30
|
+
* >>> const df2 = $df.data({ b: [2] })
|
|
31
|
+
* >>> $df.concat([df1, df2], { how: "horizontal" })
|
|
32
|
+
* shape: (1, 2)
|
|
33
|
+
* ┌───┬───┐
|
|
34
|
+
* │ a │ b │
|
|
35
|
+
* ├───┼───┤
|
|
36
|
+
* │ 1 │ 2 │
|
|
37
|
+
* └───┴───┘
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // 3. Diagonal Concatenation (mismatched columns):
|
|
41
|
+
* >>> const df1 = $df.data({ a: [1] })
|
|
42
|
+
* >>> const df2 = $df.data({ b: [2] })
|
|
43
|
+
* >>> $df.concat([df1, df2], { how: "diagonal" })
|
|
44
|
+
* shape: (2, 2)
|
|
45
|
+
* ┌──────┬──────┐
|
|
46
|
+
* │ a │ b │
|
|
47
|
+
* ├──────┼──────┤
|
|
48
|
+
* │ 1 │ null │
|
|
49
|
+
* │ null │ 2 │
|
|
50
|
+
* └──────┴──────┘
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
3
53
|
export declare function concat<U extends RowRecord = any>(rawItems: ConcatItem | ConcatItem[], { how, horizontal }?: ConcatOptions): DataFrame<U>;
|
|
@@ -4,5 +4,14 @@ import type { RowRecord } from "../types";
|
|
|
4
4
|
/**
|
|
5
5
|
* Reads a CSV string and constructs a DataFrame.
|
|
6
6
|
* Automatically infers column data types unless an explicit schema is provided.
|
|
7
|
+
* @namespace $df
|
|
8
|
+
* @category ColumnExpression
|
|
9
|
+
* @syntax $df.{symbol}(...)
|
|
10
|
+
* @param content The CSV content string.
|
|
11
|
+
* @param [options] Parse and configuration options.
|
|
12
|
+
* @param [options.hasHeader] Whether the first row is a header row (default `true`).
|
|
13
|
+
* @param [options.schema] Optional column schema to coerce types.
|
|
14
|
+
* @param [options.inferSchema] When `true` (default), automatically infers column types.
|
|
15
|
+
* @returns DataFrame
|
|
7
16
|
*/
|
|
8
17
|
export declare function read_csv<T extends RowRecord = any>(content: string, options?: ReadCSVOptions): DataFrame<T>;
|
|
@@ -2,9 +2,14 @@ import { DataFrame } from "../dataframe/dataframe";
|
|
|
2
2
|
import type { ReadJSONOptions } from "../dataframe/types";
|
|
3
3
|
/**
|
|
4
4
|
* Parses JSON content (JSON or NDJSON) and loads it into a new DataFrame.
|
|
5
|
-
*
|
|
5
|
+
* @namespace $df
|
|
6
|
+
* @category ColumnExpression
|
|
7
|
+
* @syntax $df.{symbol}(...)
|
|
6
8
|
* @param content The JSON or NDJSON content string.
|
|
7
|
-
* @param options Parse and configuration options.
|
|
9
|
+
* @param [options] Parse and configuration options.
|
|
10
|
+
* @param [options.format] Input format (`"json"` or `"ndjson"`). Default `"json"`.
|
|
11
|
+
* @param [options.trimBeforeParse] When `true` (default), trims whitespace before parsing.
|
|
12
|
+
* @param [options.schema] Optional column schema to coerce types.
|
|
8
13
|
* @returns A new DataFrame instance populated with the parsed records.
|
|
9
14
|
*/
|
|
10
15
|
export declare function read_json(content: string, { format, trimBeforeParse, schema, ...parseOpts }?: ReadJSONOptions): DataFrame<any>;
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>🚀 DFScript Interactive Playground</title>
|
|
7
|
+
<!-- Google Fonts: Outfit (headings) & Inter (body) & Fira Code (monocode) -->
|
|
8
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
|
+
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Inter:wght@300;400;500;600&family=Outfit:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-DEJEV_tU.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DBhGK6Tp.css">
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<div id="root"></div>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|