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.
Files changed (142) hide show
  1. package/README.md +203 -38
  2. package/dist/api.d.ts +16 -8
  3. package/dist/columnExpressions/ColumnExpr.d.ts +26 -364
  4. package/dist/columnExpressions/ExprBase.d.ts +8 -11
  5. package/dist/columnExpressions/constants.d.ts +2 -0
  6. package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
  7. package/dist/columnExpressions/functions/element.d.ts +5 -0
  8. package/dist/columnExpressions/functions/implode.d.ts +3 -0
  9. package/dist/columnExpressions/functions/lit.d.ts +3 -1
  10. package/dist/columnExpressions/functions/seq_range.d.ts +31 -0
  11. package/dist/columnExpressions/functions/when.d.ts +2 -2
  12. package/dist/columnExpressions/index.d.ts +6 -3
  13. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +25 -50
  14. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +43 -67
  15. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +39 -0
  16. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +31 -60
  17. package/dist/columnExpressions/mixins/ListExpr.d.ts +16 -40
  18. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +7 -33
  19. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +6 -31
  20. package/dist/columnExpressions/mixins/StringExpr.d.ts +7 -32
  21. package/dist/columnExpressions/mixins/StructExpr.d.ts +16 -0
  22. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +4 -30
  23. package/dist/columnExpressions/mixins/WindowExpr.d.ts +27 -49
  24. package/dist/columnExpressions/types.d.ts +1 -0
  25. package/dist/columnExpressions/utils.d.ts +4 -0
  26. package/dist/constants.d.ts +11 -0
  27. package/dist/dataframe/constants.d.ts +3 -0
  28. package/dist/dataframe/dataframe.d.ts +28 -11
  29. package/dist/dataframe/grouped/grouped.d.ts +2 -3
  30. package/dist/dataframe/types.d.ts +65 -1
  31. package/dist/dataframe/utils.d.ts +11 -3
  32. package/dist/datatypes/DataType.d.ts +2 -1
  33. package/dist/datatypes/index.d.ts +4 -3
  34. package/dist/datatypes/types.d.ts +42 -41
  35. package/dist/exceptions/index.d.ts +2 -0
  36. package/dist/exceptions/utils.d.ts +1 -0
  37. package/dist/functions/concat.d.ts +1 -2
  38. package/dist/functions/index.d.ts +3 -1
  39. package/dist/functions/read_csv.d.ts +8 -0
  40. package/dist/functions/read_json.d.ts +10 -0
  41. package/dist/index.js +6 -1
  42. package/dist/types.d.ts +34 -6
  43. package/dist/utils/array.d.ts +217 -0
  44. package/dist/utils/binary.d.ts +3 -0
  45. package/dist/utils/csv.d.ts +77 -0
  46. package/dist/utils/date.d.ts +21 -35
  47. package/dist/utils/guards.d.ts +11 -12
  48. package/dist/utils/index.d.ts +5 -2
  49. package/dist/utils/json.d.ts +120 -2
  50. package/dist/utils/list.d.ts +196 -2
  51. package/dist/utils/number.d.ts +47 -29
  52. package/dist/utils/object.d.ts +26 -0
  53. package/dist/utils/string.d.ts +7 -4
  54. package/package.json +6 -2
  55. package/dist/api.js +0 -18
  56. package/dist/bundle.min.js +0 -1
  57. package/dist/columnExpressions/ColumnExpr.js +0 -23
  58. package/dist/columnExpressions/ExprBase.js +0 -133
  59. package/dist/columnExpressions/constants.js +0 -5
  60. package/dist/columnExpressions/functions/all.js +0 -11
  61. package/dist/columnExpressions/functions/coalesce.js +0 -40
  62. package/dist/columnExpressions/functions/exclude.js +0 -13
  63. package/dist/columnExpressions/functions/lit.js +0 -22
  64. package/dist/columnExpressions/functions/when.js +0 -81
  65. package/dist/columnExpressions/index.js +0 -81
  66. package/dist/columnExpressions/mixins/AggregationExpr.js +0 -172
  67. package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -143
  68. package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -389
  69. package/dist/columnExpressions/mixins/ListExpr.js +0 -248
  70. package/dist/columnExpressions/mixins/LogicalExpr.js +0 -54
  71. package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -35
  72. package/dist/columnExpressions/mixins/StringExpr.js +0 -249
  73. package/dist/columnExpressions/mixins/TemporalExpr.js +0 -127
  74. package/dist/columnExpressions/mixins/WindowExpr.js +0 -281
  75. package/dist/columnExpressions/types.js +0 -2
  76. package/dist/dataframe/constants.js +0 -4
  77. package/dist/dataframe/dataframe.js +0 -749
  78. package/dist/dataframe/grouped/grouped.js +0 -113
  79. package/dist/dataframe/index.js +0 -20
  80. package/dist/dataframe/types.js +0 -2
  81. package/dist/dataframe/utils.js +0 -215
  82. package/dist/datatypes/DataType.js +0 -47
  83. package/dist/datatypes/index.js +0 -46
  84. package/dist/datatypes/types/Binary.d.ts +0 -9
  85. package/dist/datatypes/types/Binary.js +0 -18
  86. package/dist/datatypes/types/Boolean.d.ts +0 -9
  87. package/dist/datatypes/types/Boolean.js +0 -19
  88. package/dist/datatypes/types/Date.d.ts +0 -8
  89. package/dist/datatypes/types/Date.js +0 -21
  90. package/dist/datatypes/types/Datetime.d.ts +0 -8
  91. package/dist/datatypes/types/Datetime.js +0 -17
  92. package/dist/datatypes/types/Decimal.d.ts +0 -10
  93. package/dist/datatypes/types/Decimal.js +0 -28
  94. package/dist/datatypes/types/Duration.d.ts +0 -8
  95. package/dist/datatypes/types/Duration.js +0 -17
  96. package/dist/datatypes/types/Float32.d.ts +0 -8
  97. package/dist/datatypes/types/Float32.js +0 -17
  98. package/dist/datatypes/types/Float64.d.ts +0 -8
  99. package/dist/datatypes/types/Float64.js +0 -17
  100. package/dist/datatypes/types/Int16.d.ts +0 -8
  101. package/dist/datatypes/types/Int16.js +0 -17
  102. package/dist/datatypes/types/Int32.d.ts +0 -8
  103. package/dist/datatypes/types/Int32.js +0 -17
  104. package/dist/datatypes/types/Int64.d.ts +0 -8
  105. package/dist/datatypes/types/Int64.js +0 -17
  106. package/dist/datatypes/types/Int8.d.ts +0 -8
  107. package/dist/datatypes/types/Int8.js +0 -17
  108. package/dist/datatypes/types/List.d.ts +0 -10
  109. package/dist/datatypes/types/List.js +0 -31
  110. package/dist/datatypes/types/Null.d.ts +0 -9
  111. package/dist/datatypes/types/Null.js +0 -17
  112. package/dist/datatypes/types/Object.d.ts +0 -9
  113. package/dist/datatypes/types/Object.js +0 -17
  114. package/dist/datatypes/types/Struct.d.ts +0 -14
  115. package/dist/datatypes/types/Struct.js +0 -39
  116. package/dist/datatypes/types/Time.d.ts +0 -8
  117. package/dist/datatypes/types/Time.js +0 -29
  118. package/dist/datatypes/types/UInt16.d.ts +0 -8
  119. package/dist/datatypes/types/UInt16.js +0 -17
  120. package/dist/datatypes/types/UInt32.d.ts +0 -8
  121. package/dist/datatypes/types/UInt32.js +0 -17
  122. package/dist/datatypes/types/UInt64.d.ts +0 -8
  123. package/dist/datatypes/types/UInt64.js +0 -17
  124. package/dist/datatypes/types/UInt8.d.ts +0 -8
  125. package/dist/datatypes/types/UInt8.js +0 -17
  126. package/dist/datatypes/types/Utf8.d.ts +0 -10
  127. package/dist/datatypes/types/Utf8.js +0 -20
  128. package/dist/datatypes/types.js +0 -286
  129. package/dist/exceptions/index.js +0 -43
  130. package/dist/exceptions/utils.js +0 -9
  131. package/dist/functions/concat.js +0 -248
  132. package/dist/functions/index.js +0 -17
  133. package/dist/types.js +0 -2
  134. package/dist/utils/boolean.d.ts +0 -1
  135. package/dist/utils/boolean.js +0 -18
  136. package/dist/utils/date.js +0 -349
  137. package/dist/utils/guards.js +0 -143
  138. package/dist/utils/index.js +0 -21
  139. package/dist/utils/json.js +0 -33
  140. package/dist/utils/list.js +0 -128
  141. package/dist/utils/number.js +0 -223
  142. 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
- constructor(data: T[] | ColumnDict, schema?: Record<string, DataType>, height?: number);
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
- get dtypes(): DataType[];
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, options?: LimitOptions): DataFrame<T>;
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(): Record<string, DataType>;
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
- to_list<K extends keyof T>(nameOrExpr: K | IExpr): any[];
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 { DataType } from "../../datatypes";
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: Record<string, DataType>);
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): DataType;
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: any): T;
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
- List: <TInner>(inner: BaseDataType<TInner>) => import("./types").ListType<TInner>;
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: any): number | null;
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: any): number | null;
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: any): number | null;
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: any): bigint | null;
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: any): number | null;
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: any): number | null;
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: any): number | null;
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: any): bigint | null;
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: any): number | null;
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: any): number | null;
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: any): number | null;
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: any): boolean | null;
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 Boolean: BooleanType;
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: any): string | null;
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: any): Uint8Array | null;
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: any): null;
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: any): any;
118
+ coerce(val: unknown): any;
119
119
  equals(other: DataType): boolean;
120
120
  allocate(size: number): any[];
121
121
  }
122
- export declare const Object: ObjectType;
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: any): Date | null;
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 Date: DateType;
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: any): Date | null;
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: any): string | null;
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: any): number | null;
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 ListType<TInner = any> extends NestedDataType<TInner[] | null> {
152
- readonly innerType: DataType<TInner>;
153
- readonly name = "List";
154
- constructor(innerType: DataType<TInner>);
155
- coerce(val: any): TInner[] | null;
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 List: <TInner>(inner: DataType<TInner>) => ListType<TInner>;
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: any): TFields | null;
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>;
@@ -10,4 +10,6 @@ export declare class SchemaError extends DFScriptError {
10
10
  }
11
11
  export declare class ComputeError extends DFScriptError {
12
12
  }
13
+ export declare class ShapeError extends DFScriptError {
14
+ }
13
15
  export * from "./utils";
@@ -1,2 +1,3 @@
1
1
  import type { ColumnDict } from "../types";
2
2
  export declare function assertColumnExists(columnName: string, columns: ColumnDict, context: string, suffix?: string): void;
3
+ export declare function assertHeight(columns: ColumnDict, height?: number): number;
@@ -1,4 +1,3 @@
1
1
  import { DataFrame } from "../dataframe/dataframe";
2
2
  import type { ConcatOptions, ConcatItem, RowRecord } from "../types";
3
- export declare function normalizeToDataFrames(item: any, context: string, index: number): DataFrame<any>[];
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>;
@@ -1 +1,3 @@
1
- export * from "./concat";
1
+ export { concat } from "./concat";
2
+ export { read_json } from "./read_json";
3
+ export { read_csv } from "./read_csv";
@@ -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>;