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,4 +1,4 @@
1
- export type ArrayItemType = "string" | "number" | "boolean" | "bigint" | "object" | "plainObject" | "date" | (new (...args: any[]) => any) | ((v: unknown) => boolean);
1
+ export type ArrayItemType = "string" | "number" | "boolean" | "bigint" | "object" | "plainObject" | "date" | "any" | "null" | "undefined" | "nullish" | (new (...args: any[]) => any) | ((v: unknown) => boolean);
2
2
  export type ArrayCheckMode = "every" | "some";
3
3
  export type IsArrayOfTypeOptionsParams = {
4
4
  mode?: ArrayCheckMode;
@@ -6,8 +6,16 @@ export type IsArrayOfTypeOptionsParams = {
6
6
  allowEmpty?: boolean;
7
7
  };
8
8
  export declare function toValidArray<T>(val: T | T[] | null | undefined): T[];
9
+ export declare function toValidStringArray(val: unknown): string[];
9
10
  export declare function isArrayOfType(arr: unknown, type: ArrayItemType, { mode, allowNulls, allowEmpty }?: IsArrayOfTypeOptionsParams): boolean;
10
- export declare function sortList(arr: unknown, descending?: boolean): any[];
11
+ export interface SortListOptions {
12
+ descending?: boolean;
13
+ nullsLast?: boolean;
14
+ isAllNumbers?: boolean;
15
+ isAllStrings?: boolean;
16
+ hasNulls?: boolean;
17
+ }
18
+ export declare function sortList(arr: unknown, options?: SortListOptions): any[];
11
19
  export declare function getListStats(arr: unknown): {
12
20
  sum: number | null;
13
21
  count: number;
@@ -21,3 +29,189 @@ export declare function getListStats(arr: unknown): {
21
29
  hasNulls: boolean;
22
30
  isNumeric: boolean;
23
31
  };
32
+ /**
33
+ * Options configuration for the `getUniqueListStats` utility.
34
+ */
35
+ export interface UniqueListStatsOptions {
36
+ /**
37
+ * If true, uses strict serialization comparison (via keySelector or toCanonicalString)
38
+ * to group complex nested types (like Arrays, Sets, Maps, and Dates) by value instead of reference.
39
+ * @default false
40
+ */
41
+ strict?: boolean;
42
+ /**
43
+ * Custom function to extract a unique comparison key from each element.
44
+ * If strict is true and no selector is provided, falls back to `toCanonicalString`.
45
+ */
46
+ keySelector?: (val: any) => any;
47
+ }
48
+ export declare function getUniqueListStats(arr: ArrayLike<any>, { strict, keySelector }?: UniqueListStatsOptions): {
49
+ values: any[];
50
+ count: number;
51
+ frequencies: Map<any, number>;
52
+ };
53
+ /**
54
+ * Options configuration for the `stepSliceList` utility.
55
+ */
56
+ export interface StepSliceListOptions {
57
+ /**
58
+ * The step size to slice the list by. Cannot be zero.
59
+ * Positive values slice forward (left-to-right), negative values slice backward (right-to-left).
60
+ * @default 1
61
+ */
62
+ step?: number;
63
+ /**
64
+ * The index to start slicing from (inclusive).
65
+ * Supports negative values to start relative to the end of the array.
66
+ * @default 0
67
+ */
68
+ offsetStart?: number;
69
+ /**
70
+ * The index to end slicing at (exclusive).
71
+ * Supports negative values to end relative to the end of the array.
72
+ * Defaults to the end of the array (if step > 0) or -1 (if step < 0).
73
+ */
74
+ offsetEnd?: number;
75
+ /**
76
+ * Caps the maximum number of items gathered in the sliced result list.
77
+ * If specified, the slicing process stops once this limit is reached.
78
+ */
79
+ maxItemsGathered?: number;
80
+ /**
81
+ * If true, returns null when the starting offset is out of bounds.
82
+ * If false, throws an error when the starting offset is out of bounds.
83
+ * @default true
84
+ */
85
+ null_on_oob?: boolean;
86
+ }
87
+ export declare function stepSliceList<T>(arr: ArrayLike<T>, { step, offsetStart, offsetEnd, maxItemsGathered, null_on_oob }?: StepSliceListOptions): T[] | null;
88
+ /**
89
+ * Options configuration for the `joinList` utility.
90
+ */
91
+ export interface JoinListOptions {
92
+ /**
93
+ * If true, nullish elements (null and undefined) are completely ignored during joining.
94
+ * If false (default), nullish elements are serialized as empty strings or custom `nullValue`.
95
+ * @default false
96
+ */
97
+ ignoreNulls?: boolean;
98
+ /**
99
+ * Custom string representation for nullish values.
100
+ * Only applied if `ignoreNulls` is false.
101
+ * @default ""
102
+ */
103
+ nullValue?: string;
104
+ /**
105
+ * Optional prefix string prepended to the final joined result.
106
+ * @default ""
107
+ */
108
+ prefix?: string;
109
+ /**
110
+ * Optional suffix string appended to the final joined result.
111
+ * @default ""
112
+ */
113
+ suffix?: string;
114
+ /**
115
+ * Maximum number of list elements to join.
116
+ * If specified, elements beyond this limit are omitted and `truncationMarker` is appended.
117
+ */
118
+ limit?: number;
119
+ /**
120
+ * Custom placeholder string appended to the joined string when limit truncation occurs.
121
+ * Only applied if `limit` is specified and the list length exceeds it.
122
+ * @default "..."
123
+ */
124
+ truncationMarker?: string;
125
+ /**
126
+ * Callback function used to format each individual non-null element to a custom string representation.
127
+ */
128
+ valueFormatter?: (val: any, index: number) => string;
129
+ }
130
+ /**
131
+ * Joins the elements of an array-like structure into a string using a separator.
132
+ * Excludes nullish checks and formats nested arrays cleanly.
133
+ */
134
+ export declare function joinList(arr: ArrayLike<any>, separator?: string, { ignoreNulls, nullValue, prefix, suffix, limit, truncationMarker, valueFormatter }?: JoinListOptions): string;
135
+ export interface FillSeqBaseOptions {
136
+ /**
137
+ * Type coercion helper applied to each generated value before writing.
138
+ *
139
+ * @param v The newly generated candidate value.
140
+ * @returns The coerced value to write to the array.
141
+ */
142
+ coerce?: (v: any) => any;
143
+ /**
144
+ * Conditional predicate determining if a value should be replaced at a given index.
145
+ *
146
+ * @param v The original/current value at the target index.
147
+ * @param index The absolute index of the current element.
148
+ * @param array The entire target array.
149
+ * @returns True if the candidate value should overwrite the original value, false otherwise.
150
+ */
151
+ condition?: (v: any, index: number, array: any[]) => boolean;
152
+ /**
153
+ * If true, iterates and populates in reverse (from startIndex down to endIndex).
154
+ * @default false
155
+ */
156
+ reverse?: boolean;
157
+ /**
158
+ * The index at which array iteration and writing begins.
159
+ * @default reverse ? length - 1 : 0
160
+ */
161
+ startIndex?: number;
162
+ /**
163
+ * The exclusive boundary index at which iteration and writing stops.
164
+ * @default reverse ? -1 : length
165
+ */
166
+ endIndex?: number;
167
+ }
168
+ export interface CumulativeStepContext {
169
+ /** The accumulated value returned by the step function from the previous stepped index. */
170
+ prev: any;
171
+ /** The relative iteration counter of the stepping process (starts at 1). */
172
+ index: number;
173
+ /** The original value at the current index in the target array. */
174
+ originalValue: any;
175
+ /** The absolute index of the current element in the parent array. */
176
+ absoluteIndex: number;
177
+ /** The entire target array being populated/modified. */
178
+ targetArray: any;
179
+ }
180
+ export interface IndependentStepContext {
181
+ /** The relative iteration counter of the generation process (starts at 0). */
182
+ index: number;
183
+ /** The static starting value passed to the sequence generator. */
184
+ initialValue: any;
185
+ /** The original value at the current index in the target array. */
186
+ originalValue: any;
187
+ /** The absolute index of the current element in the parent array. */
188
+ absoluteIndex: number;
189
+ /** The entire target array being populated/modified. */
190
+ targetArray: any;
191
+ }
192
+ export type FillSeqOptions = FillSeqBaseOptions & ({
193
+ mode: "constant";
194
+ step?: never;
195
+ } | {
196
+ mode?: "cumulative";
197
+ step?: number | ((context: CumulativeStepContext) => any);
198
+ } | {
199
+ mode: "independent";
200
+ step?: number | ((context: IndependentStepContext) => any);
201
+ });
202
+ export declare function fillSequence(targetArray: any, initialValue: any, options?: FillSeqOptions): void;
203
+ /**
204
+ * Computes the median of a numeric array, filtering out non-numeric and NaN values.
205
+ * Returns null if no valid numbers remain.
206
+ */
207
+ export declare function computeMedian(values: ArrayLike<any>): number | null;
208
+ /**
209
+ * Computes the quantile of a numeric array using linear interpolation, filtering out non-numeric and NaN values.
210
+ * q must be in [0, 1]. Returns null if no valid numbers remain or q is out of bounds.
211
+ */
212
+ export declare function computeQuantile(values: ArrayLike<any>, q: number): number | null;
213
+ /**
214
+ * Computes the mode(s) of an array, filtering out null/undefined values.
215
+ * Returns an array of the most frequent values, sorted, or null if empty/no mode.
216
+ */
217
+ export declare function computeMode(values: ArrayLike<any>): any[] | null;
@@ -1,24 +1,34 @@
1
- export declare function isValidNumber(v: unknown): v is number;
2
- export declare function toValidNumber(v: unknown): number | null;
3
- export declare function clamp<T extends number | bigint>(opts: {
4
- val: T;
5
- min: T;
6
- max: T;
7
- }): T;
1
+ export interface NumericValidationOptions {
2
+ allowNonFiniteNumbers?: boolean;
3
+ allowNaN?: boolean;
4
+ }
5
+ export declare function isValidNumber(v: unknown, options?: NumericValidationOptions): v is number;
6
+ export interface ParseNumberOptions extends NumericValidationOptions {
7
+ strictNumericString?: boolean;
8
+ floatScientific?: boolean;
9
+ }
10
+ export declare function toValidNumber(v: unknown, { allowNonFiniteNumbers, strictNumericString, floatScientific }?: ParseNumberOptions): number | null;
11
+ export interface NumericFormatOptions extends Intl.NumberFormatOptions {
12
+ /** BCP 47 language tag (e.g., 'en-US' for dot, 'de-DE' for comma). Defaults to 'en-US'. */
13
+ locale?: string;
14
+ /** If true, formats negative numbers in parentheses e.g. (1.23) instead of -1.23. */
15
+ accountingNegatives?: boolean;
16
+ /** Fallback string if the value cannot be parsed into a formatable number. */
17
+ fallback?: string;
18
+ /** If true, returns the fallback string for Infinity and -Infinity values. */
19
+ formatNonFinite?: boolean;
20
+ }
21
+ /**
22
+ * Formats any numeric value (number, bigint, numeric string, Date, etc.) for output,
23
+ * handling NaN, Infinity, scientific notation, precision, and accounting formats.
24
+ */
25
+ export declare function formatNumber({ locale, accountingNegatives, fallback, formatNonFinite, ...intlOpts }?: NumericFormatOptions): (value: unknown) => string;
8
26
  export type FloatPrecision = "Float32" | "Float64";
9
- export declare const FLOAT_32_BOUNDARY = 3.4028234663852886e+38;
10
- export declare const FLOAT_RANGES: {
11
- readonly Float32: {
12
- readonly min: number;
13
- readonly max: 3.4028234663852886e+38;
14
- };
15
- readonly Float64: {
16
- readonly min: number;
17
- readonly max: number;
18
- };
19
- };
20
- export declare function isValidFloat(v: unknown, precision?: FloatPrecision): boolean;
21
- export declare function toValidFloat(v: unknown, precision?: FloatPrecision): number | null;
27
+ export interface FloatOptions extends ParseNumberOptions {
28
+ floatPrecision?: FloatPrecision;
29
+ }
30
+ export declare function isValidFloat(v: unknown, { floatPrecision, allowNonFiniteNumbers }?: FloatOptions): v is number;
31
+ export declare function toValidFloat(v: unknown, { floatPrecision, allowNonFiniteNumbers, floatScientific, strictNumericString }?: FloatOptions): number | null;
22
32
  export declare const INT_RANGES: {
23
33
  readonly Int8: {
24
34
  readonly min: -128;
@@ -50,6 +60,12 @@ export type IntRange = {
50
60
  min: number;
51
61
  max: number;
52
62
  } | IntRangeType;
63
+ export type IntCoerceType = "round" | "floor" | "ceil" | "truncate";
64
+ export interface IntOptions {
65
+ range?: IntRange;
66
+ coerce?: IntCoerceType;
67
+ }
68
+ export declare function toValidInt(v: unknown, { range, coerce }?: IntOptions): number | null;
53
69
  export declare const BIGINT_RANGES: {
54
70
  readonly Int64: {
55
71
  readonly min: -9223372036854775808n;
@@ -65,20 +81,22 @@ export type BigIntRange = {
65
81
  min: bigint;
66
82
  max: bigint;
67
83
  } | BigIntRangeType;
68
- export type IntCoerceType = "round" | "floor" | "ceil" | "truncate";
69
- export interface IntOptions {
70
- coerce?: IntCoerceType;
84
+ export interface BigIntOptions {
85
+ range?: BigIntRange;
86
+ truncate?: boolean;
71
87
  }
72
- export declare function isValidInt(v: unknown, range?: IntRange): v is number;
73
- export declare function isValidBigInt(v: unknown, range?: BigIntRange): v is bigint;
74
- export declare function toValidInt(v: unknown, range?: IntRange, opts?: IntOptions): number | null;
75
- export declare function toValidBigInt(v: unknown, range?: BigIntRange): bigint | null;
88
+ export declare function toValidBigInt(v: unknown, { range, truncate }?: BigIntOptions): bigint | null;
76
89
  export interface DecimalOptions {
77
90
  precision?: number;
78
91
  scale?: number;
79
92
  }
80
- export declare function isValidDecimal(v: unknown, opts?: DecimalOptions): boolean;
81
- export declare function toValidDecimal(v: unknown, opts?: DecimalOptions): number | null;
93
+ export declare function roundToScale(v: number, scale: number): number;
94
+ export declare function toValidDecimal(v: unknown, { precision, scale }?: DecimalOptions): number | null;
95
+ export declare function clamp<T extends number | bigint>(val: T, options?: {
96
+ min?: T | null;
97
+ max?: T | null;
98
+ safe?: boolean;
99
+ }): T;
82
100
  /**
83
101
  * Creates a seedable pseudo-random number generator using the Mulberry32 PRNG algorithm.
84
102
  * Returns a function that generates a pseudo-random float in the range [0, 1).
@@ -0,0 +1,26 @@
1
+ export declare const TAG_DATE = "[object Date]";
2
+ export declare const TAG_REGEXP = "[object RegExp]";
3
+ export declare const TAG_SET = "[object Set]";
4
+ export declare const TAG_MAP = "[object Map]";
5
+ export declare const TAG_ERROR = "[object Error]";
6
+ export declare const TAG_URL_PARAMS = "[object URLSearchParams]";
7
+ export declare const TAG_STRING = "[object String]";
8
+ export declare const TAG_NUMBER = "[object Number]";
9
+ export declare const TAG_BOOLEAN = "[object Boolean]";
10
+ export declare const TAG_BIGINT = "[object BigInt]";
11
+ export declare const TAG_SYMBOL = "[object Symbol]";
12
+ export declare function isObj(v: unknown): v is Record<PropertyKey, unknown>;
13
+ export declare function isPlainObj(v: unknown): v is Record<PropertyKey, unknown>;
14
+ export declare function isClass(v: unknown): v is new (...args: any[]) => any;
15
+ export declare function isValidDateObj(v: unknown): v is Date;
16
+ export declare function isRegExp(v: unknown): v is RegExp;
17
+ export declare function isSet(v: unknown): v is Set<unknown>;
18
+ export declare function isMap(v: unknown): v is Map<unknown, unknown>;
19
+ export declare function isURLSearchParams(v: unknown): v is URLSearchParams;
20
+ export declare function isError(v: unknown): v is Error;
21
+ export declare function isStringObj(v: unknown): v is String;
22
+ export declare function isNumberObj(v: unknown): v is Number;
23
+ export declare function isBooleanObj(v: unknown): v is Boolean;
24
+ export declare function isBigIntObj(v: unknown): v is Object;
25
+ export declare function isSymbolObj(v: unknown): v is Object;
26
+ export declare function unboxPrimitiveObj(v: unknown): unknown;
@@ -1,3 +1,5 @@
1
+ export declare function isBlankString(v: unknown): v is string;
2
+ export declare function escapeRegExp(val: unknown): string;
1
3
  export type StripMode = "both" | "start" | "end";
2
4
  export type StripCharsOptions = {
3
5
  /**
@@ -46,7 +48,8 @@ export type StripCharsOptions = {
46
48
  caseInsensitive?: boolean;
47
49
  };
48
50
  };
49
- /**
50
- * Strips characters from the start, end, or both ends of a string.
51
- */
52
- export declare function stripChars(str: string | null | undefined, characters?: string | RegExp | null, { mode, returnStringOnNull, maxScanStart, maxScanEnd, maxMatchesStart, maxMatchesEnd, trimFirst, stringOptions: { literal, caseInsensitive } }?: StripCharsOptions): string | null;
51
+ export declare function stripChars(str: string | null | undefined, characters?: string | RegExp | null, options?: StripCharsOptions): string | null;
52
+ export declare function toCanonicalString(val: any, { depth, maxDepth }?: {
53
+ depth?: number;
54
+ maxDepth?: number;
55
+ }): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "df-script",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "A zero-dependency, high-performance, expression-based DataFrame library for TypeScript/JavaScript.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "README.md"
11
11
  ],
12
12
  "scripts": {
13
- "build": "tsc && esbuild src/index.ts --bundle --minify --outfile=dist/index.js --platform=node",
13
+ "build": "tsc --emitDeclarationOnly && esbuild src/index.ts --bundle --minify --outfile=dist/index.js --platform=node",
14
14
  "test": "tsx _tests/run_all_project_tests.ts",
15
15
  "prepublishOnly": "npm run build"
16
16
  },
@@ -26,6 +26,10 @@
26
26
  ],
27
27
  "author": "Trent Morris",
28
28
  "license": "MIT",
29
+ "funding": {
30
+ "type": "custom",
31
+ "url": "https://github.com/trentamorris/df-script/blob/main/DONATIONS.md"
32
+ },
29
33
  "devDependencies": {
30
34
  "typescript": "^5.4.5",
31
35
  "tsx": "^4.15.5",
package/dist/api.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.$tbl = void 0;
4
- const dataframe_1 = require("./dataframe");
5
- const columnExpressions_1 = require("./columnExpressions");
6
- const datatypes_1 = require("./datatypes");
7
- const functions_1 = require("./functions");
8
- exports.$tbl = {
9
- data: (data, schema) => new dataframe_1.DataFrame(data, schema),
10
- col: (name) => new columnExpressions_1.ColumnExpr(name),
11
- all: columnExpressions_1.all,
12
- exclude: columnExpressions_1.exclude,
13
- coalesce: columnExpressions_1.coalesce,
14
- concat: functions_1.concat,
15
- lit: columnExpressions_1.lit,
16
- when: columnExpressions_1.when,
17
- DataType: datatypes_1.DataTypeRegistry
18
- };
@@ -1 +0,0 @@
1
- "use strict";var Vt=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var bn=Object.getOwnPropertyNames;var wn=Object.prototype.hasOwnProperty;var _n=(s,t)=>{for(var e in t)Vt(s,e,{get:t[e],enumerable:!0})},Tn=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of bn(t))!wn.call(s,r)&&r!==e&&Vt(s,r,{get:()=>t[r],enumerable:!(n=xn(t,r))||n.enumerable});return s};var Dn=s=>Tn(Vt({},"__esModule",{value:!0}),s);var Mn={};_n(Mn,{$tbl:()=>On,ALL_COLUMNS_MARKER:()=>j,AggregationExpr:()=>Ht,ArithmeticExpr:()=>Wt,ColumnExpr:()=>k,ColumnNotFoundError:()=>B,ComparisonExpr:()=>qt,ComputeError:()=>nt,DataFrame:()=>F,DataFrameError:()=>V,DataType:()=>K,DataTypeRegistry:()=>L,DateTimeExprNamespace:()=>Ut,ExprBase:()=>wt,FrameScriptError:()=>ut,GroupedData:()=>Tt,LITERAL_MARKER:()=>Pt,ListExpr:()=>Xt,ListExprNamespace:()=>vt,LogicalExpr:()=>Yt,SchemaError:()=>ct,StringExpr:()=>zt,StringExprNamespace:()=>Mt,TemporalExpr:()=>Zt,When:()=>Ft,WhenThen:()=>_t,WhenThenChain:()=>Rt,WindowExpr:()=>Gt,all:()=>Jt,coalesce:()=>te,columnsToRows:()=>Ae,concat:()=>Dt,derive:()=>g,exclude:()=>Qt,getRowFromColumns:()=>En,inferColumnType:()=>rt,kleeneBinary:()=>v,kleeneUnary:()=>_,lit:()=>it,normalizeToDataFrames:()=>dn,resolveColumnSelectors:()=>ft,resolveWindowExpr:()=>jt,rowsToColumns:()=>De,when:()=>ee});module.exports=Dn(Mn);var ke=/[,\s_]/g,An=/^[+-]?\d+(?:\.\d+)?$/;function ot(s){return typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s)}function et(s){if(s==null||typeof s=="symbol")return null;if(ot(s))return s;if(typeof s=="boolean")return s?1:0;if(typeof s=="bigint"){let t=Number(s);return ot(t)?t:null}if(s instanceof Date){let t=s.getTime();return ot(t)?t:null}if(typeof s=="string"){let t=s.trim().replace(ke,"");if(t==="")return null;let e=Number(t);return ot(e)?e:null}return null}function yt(s){let{val:t,min:e,max:n}=s;return t<e?e:t>n?n:t}var Se=34028234663852886e22,vn={Float32:{min:-Se,max:Se},Float64:{min:-Number.MAX_VALUE,max:Number.MAX_VALUE}};function At(s,t="Float64"){let e=et(s);return e===null?null:t==="Float32"?Math.fround(e):e}var Ee={Int8:{min:-128,max:127},Int16:{min:-32768,max:32767},Int32:{min:-2147483648,max:2147483647},UInt8:{min:0,max:255},UInt16:{min:0,max:65535},UInt32:{min:0,max:4294967295}},In={Int64:{min:-9223372036854775808n,max:9223372036854775807n},UInt64:{min:0n,max:18446744073709551615n}};function Oe(s,t){if(!ot(s)||!Number.isInteger(s))return!1;if(!t)return!0;let e=typeof t=="string"?Ee[t]:t;return s>=e.min&&s<=e.max}function H(s,t="Int32",e={}){let n=et(s);if(n===null)return null;let r=n;switch(e.coerce||"truncate"){case"round":r=Math.round(r);break;case"floor":r=Math.floor(r);break;case"ceil":r=Math.ceil(r);break;case"truncate":r=Math.trunc(r);break}let i=typeof t=="string"?Ee[t]:t;return yt({val:r,min:i.min,max:i.max})}function It(s,t="Int64"){if(s==null||typeof s=="symbol")return null;let e=null;if(typeof s=="bigint")e=s;else if(typeof s=="boolean")e=s?1n:0n;else if(typeof s=="string"){let r=s.trim().replace(ke,"");if(r==="")return null;if(An.test(r))e=BigInt(r.split(".")[0]);else{let o=et(s);if(o===null)return null;e=BigInt(Math.trunc(o))}}else{let r=et(s);if(r===null)return null;e=BigInt(Math.trunc(r))}let n=typeof t=="string"?In[t]:t;return yt({val:e,min:n.min,max:n.max})}function Ct(s,t={}){let e=et(s);if(e===null)return null;let{precision:n,scale:r}=t,o=e;if(r!==void 0){let i=Math.pow(10,r);o=Math.round(o*i)/i}if(n!==void 0){let i=r||0,l=n-i;if(l>0){let a=Math.pow(10,l)-Math.pow(10,-i);o=yt({val:o,min:-a,max:a})}}return o}function Me(s){let t=s|0;return function(){let e=t=t+1831565813|0;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var St=/^\d{2}:\d{2}/,kt=/(?:Z|[+-]\d{2}(?::?\d{2})?)$/i;var Bt=1e3,ve=6e4,Re=36e5,dt=864e5,Et=1e3,Ot=1e6;function Fe(s,t="ms"){let e=s.getTime();switch(t){case"s":return Math.floor(e/Bt);case"ms":return e;case"us":return e*Et;case"ns":return e*Ot}}function Ne(s){let t=s.getUTCFullYear();return Math.floor((t-1)/100)+1}function Le(s){let t=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let n=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-n.getTime())/dt+1)/7)}function je(s){let t=s.getUTCFullYear();return Math.floor((t-1)/1e3)+1}function Kt(s,t,e=1){return new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth()+t,e,0,0,0,0))}function Ve(s){let t=new Date(Date.UTC(s.getUTCFullYear(),0,1)),e=s.getTime()-t.getTime();return Math.floor(e/dt)+1}function Be(s){return Math.floor(s.getUTCMonth()/3)+1}function Ke(s){let t=s instanceof Date?s.getUTCFullYear():s;return t%4===0&&t%100!==0||t%400===0}function z(s){return s instanceof Date&&!Number.isNaN(s.getTime())}function Ue(s){let t=Math.abs(s);return t>=1e12?s:t<=1e10?s*1e3:s}var Cn=["%ms","%f","%Y","%y","%m","%d","%e","%H","%I","%p","%M","%S","%A","%a","%B","%b","%h","%j","%u","%w","%Z","%z"];function $e(s,t,e){let n=t;n=n.replace(/%%/g,"\0"),n=n.replace(/%F/g,"%Y-%m-%d"),n=n.replace(/%T/g,"%H:%M:%S"),n=n.replace(/%R/g,"%H:%M"),n=n.replace(/%D/g,"%m/%d/%y");let r={get"%Y"(){return String(s.getUTCFullYear())},get"%y"(){return String(s.getUTCFullYear()%100).padStart(2,"0")},get"%m"(){return String(s.getUTCMonth()+1).padStart(2,"0")},get"%d"(){return String(s.getUTCDate()).padStart(2,"0")},get"%e"(){return String(s.getUTCDate()).padStart(2," ")},get"%H"(){return String(s.getUTCHours()).padStart(2,"0")},get"%I"(){return String(s.getUTCHours()%12||12).padStart(2,"0")},get"%p"(){return s.getUTCHours()>=12?"PM":"AM"},get"%M"(){return String(s.getUTCMinutes()).padStart(2,"0")},get"%S"(){return String(s.getUTCSeconds()).padStart(2,"0")},get"%A"(){return s.toLocaleDateString(e,{weekday:"long",timeZone:"UTC"})},get"%a"(){return s.toLocaleDateString(e,{weekday:"short",timeZone:"UTC"})},get"%B"(){return s.toLocaleDateString(e,{month:"long",timeZone:"UTC"})},get"%b"(){return s.toLocaleDateString(e,{month:"short",timeZone:"UTC"})},get"%h"(){return s.toLocaleDateString(e,{month:"short",timeZone:"UTC"})},get"%j"(){let o=new Date(Date.UTC(s.getUTCFullYear(),0,1)),i=s.getTime()-o.getTime(),l=Math.floor(i/dt)+1;return String(l).padStart(3,"0")},get"%u"(){return String(s.getUTCDay()||7)},get"%w"(){return String(s.getUTCDay())},get"%Z"(){return"UTC"},get"%z"(){return"+0000"},get"%ms"(){return String(s.getUTCMilliseconds()).padStart(3,"0")},get"%f"(){return String(s.getUTCMilliseconds()*1e3).padStart(6,"0")}};for(let o of Cn)n.includes(o)&&(n=n.replaceAll(o,r[o]));return n.replace(/\0/g,"%")}function Pe(s,t,e=!0){if(typeof s!="string"||typeof t!="string")return null;let n=[],r=1,o="",i=0;for(;i<t.length;){let b=t[i];if(b==="%")if(i+1<t.length){let w=t[i+1];if(w==="%")o+="%",i+=2;else if(t.slice(i,i+3)==="%ms")n.push({name:"ms",index:r++}),o+="(\\d{1,3})",i+=3;else{switch(w){case"Y":n.push({name:"year",index:r++}),o+="(\\d{4})";break;case"y":n.push({name:"year_short",index:r++}),o+="(\\d{2})";break;case"m":n.push({name:"month",index:r++}),o+="(\\d{1,2})";break;case"d":case"e":n.push({name:"day",index:r++}),o+="(\\d{1,2})";break;case"H":case"I":n.push({name:"hour",index:r++}),o+="(\\d{1,2})";break;case"M":n.push({name:"minute",index:r++}),o+="(\\d{1,2})";break;case"S":n.push({name:"second",index:r++}),o+="(\\d{1,2})";break;case"f":n.push({name:"fractional",index:r++}),o+="(\\d{1,6})";break;default:o+=b+w}i+=2}}else o+=b,i++;else"\\^$*+?.()|[]{}".indexOf(b)!==-1?o+="\\"+b:o+=b,i++}let l=new RegExp("^"+o+"$"),a=s.match(l);if(!a){if(e)return null;let b=new Date(s);return z(b)?b:null}let u=1970,c=1,f=1,h=0,p=0,m=0,y=0;for(let b of n){let w=a[b.index],A=parseInt(w,10);switch(b.name){case"year":u=A;break;case"year_short":u=A+(A>=69?1900:2e3);break;case"month":c=A;break;case"day":f=A;break;case"hour":h=A;break;case"minute":p=A;break;case"second":m=A;break;case"ms":y=parseInt(w.padEnd(3,"0").slice(0,3),10);break;case"fractional":y=parseInt(w.padEnd(6,"0").slice(0,3),10);break}}let d=new Date(Date.UTC(u,c-1,f,h,p,m,y));return z(d)?d:null}function Y(s){if(s instanceof Date)return z(s)?s:null;if(typeof s=="number"){let t=new Date(Ue(s));return z(t)?t:null}if(typeof s=="bigint"){let t=new Date(Ue(Number(s)));return z(t)?t:null}if(typeof s=="string"){let t=s.trim();if(t==="")return null;let e=new Date(t);return z(e)?e:null}return null}function P(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function C(s){return Array.isArray(s)||P(s)}function Z(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function xt(s){if(!Z(s))return!1;let t=Object.getPrototypeOf(s);return t===null||t===Object.prototype}function We(s){return typeof s!="function"?!1:/^class\s/.test(Function.prototype.toString.call(s))||s.prototype!==void 0&&s.prototype.constructor===s&&Object.getOwnPropertyDescriptor(s,"prototype")?.writable===!1}function Sn(s){if(s==null)return!1;if(s instanceof Uint8Array||typeof s=="string")return!0;if(Array.isArray(s)){let t=s.length;for(let e=0;e<t;e++)if(!Oe(s[e],{min:-128,max:255}))return!1;return!0}return!!P(s)}function qe(s){return Sn(s)?s instanceof Uint8Array?s:typeof s=="string"?new TextEncoder().encode(s):ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s):null}function st(s){return s==null?[]:Array.isArray(s)?s:P(s)?Array.from(s):[s]}function lt(s,t,{mode:e="every",allowNulls:n=!1,allowEmpty:r=!0}={}){if(!C(s))return!1;let o=s.length;if(o===0)return r?e==="every":!1;let i=l=>l==null?n:typeof t=="function"?We(t)?l instanceof t:t(l):t==="date"?z(l):t==="object"?Z(l):t==="plainObject"?xt(l):t==="number"?ot(l):typeof l===t;if(e==="every"){for(let l=0;l<o;l++)if(!i(s[l]))return!1;return!0}else{for(let l=0;l<o;l++)if(i(s[l]))return!0;return!1}}function $t(s,t=!1){if(!C(s))return[];let e=Array.from(s);return e.sort((n,r)=>n==null&&r==null?0:n==null?1:r==null?-1:n<r?t?1:-1:n>r?t?-1:1:0),e}function bt(s){if(!C(s))return{sum:null,count:0,min:null,max:null};let t=s.length;if(t===0)return{sum:null,count:0,min:null,max:null};let e=0,n=0,r=null,o=null;for(let i=0;i<t;i++){let l=s[i];if(l==null)continue;(r==null||l<r)&&(r=l),(o==null||l>o)&&(o=l);let a=et(l);a!==null&&(e+=a,n++)}return{sum:n>0?e:null,count:n,min:r,max:o}}function He(s){if(!lt(s,"number",{allowNulls:!0}))return null;let t=s.length,e=[];for(let r=0;r<t;r++){let o=s[r];o!=null&&e.push(o)}if(e.length===0)return null;e.sort((r,o)=>r-o);let n=Math.floor(e.length/2);return e.length%2!==0?e[n]:(e[n-1]+e[n])/2}function Ge(s){if(!C(s))return null;let t=s.length,e=new Map,n=0;for(let o=0;o<t;o++){let i=s[o];if(i==null)continue;let l=(e.get(i)??0)+1;e.set(i,l),l>n&&(n=l)}if(n===0)return[];let r=[];for(let[o,i]of e.entries())i===n&&r.push(o);return $t(r)}function at(s,t=null,{mode:e="both",returnStringOnNull:n=!1,maxScanStart:r=1,maxScanEnd:o=1,maxMatchesStart:i=1,maxMatchesEnd:l=1,trimFirst:a=!1,stringOptions:{literal:u=!1,caseInsensitive:c=!1}={}}={}){if(s==null)return n?"":null;let f=(x,I="both")=>I==="start"?x.trimStart():I==="end"?x.trimEnd():x.trim(),h=s;if(a&&t!=null&&(h=f(s,e)),t==null){let x=f(h,e);return n||x!==""?x:null}let p=t instanceof RegExp?x=>t.test(x):(()=>{let x=new Set(c?t.toLowerCase():t);return I=>x.has(c?I.toLowerCase():I)})(),m=h.length,y=new Uint8Array(m),A=u&&typeof t=="string"?({isStart:x,limit:I,maxMatches:U})=>{if(m===0||U===0)return;let E=t.length;if(E===0)return;let N=c?h.toLowerCase():h,$=c?t.toLowerCase():t,T=x?0:m-1,D=0,O=0;for(;T>=0&&T<m&&!(U!==null&&U>=0&&D>=U);){let R=x?T:T-E+1;if(!x&&R<0)break;let M=x?N.indexOf($,R):N.lastIndexOf($,R);if(M===-1)break;let q=x?M-T:T-(M+E-1);if(O+=q,I!==null&&I>=0&&O>=I)break;for(let G=0;G<E;G++)y[M+G]=1;D++,T=x?M+E:M-1}}:({isStart:x,limit:I,maxMatches:U})=>{if(m===0||U===0)return;let E=x?0:m-1,N=x?m:-1,$=x?1:-1,T=!1,D=0,O=0;for(let R=E;R!==N;R+=$)if(p(h[R])){if(!T){if(I!==null&&I>=0&&O>=I||U!==null&&U>=0&&D>=U)break;T=!0,D++}y[R]=1}else T=!1,O++};(e==="both"||e==="start")&&A({isStart:!0,limit:r,maxMatches:i}),(e==="both"||e==="end")&&A({isStart:!1,limit:o,maxMatches:l});let S="";for(let x=0;x<m;x++)y[x]===0&&(S+=h[x]);return n||S!==""?S:null}var j="*",Pt="*literal*";var _=s=>t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++){let o=t[r];n[r]=o==null?null:s(o)}return n},v=(s,t,e)=>(n,r)=>{let o=n.length,i=s._resolve(t,r,o),l=new Array(o);if(C(i))for(let a=0;a<o;a++){let u=n[a],c=i[a];l[a]=u==null||c==null?null:e(u,c)}else for(let a=0;a<o;a++){let u=n[a];l[a]=u==null||i==null?null:e(u,i)}return l},g=(s,t)=>{let e=s.constructor,n=new e(s.colName||"");return Object.assign(n,s),n.ops=t?[...s.ops,t]:[...s.ops],n},wt=class{ops=[];outputName="";aggFn=null;groupingOpsIndex;partitionOpsIndex;partitionBy=null;_resolve(t,e,n){return t&&typeof t=="object"&&"evaluate"in t?t.isLiteral&&t.ops.length===1?t.literalValue:t.evaluate(e,n):t}alias(t){let e=this.constructor,n=new e(this.colName||"");return Object.assign(n,this),n.outputName=t,n}cast(t){return g(this,e=>{let n=e.length,r=new Array(n);for(let o=0;o<n;o++)r[o]=t.coerce(e[o]);return r})}debug(t){return g(this,e=>(console.log(`[DEBUG] ${t?t+": ":""}`,e),e))}evaluate(t,e){let n=this.colName,r=n&&n!=="*"?t[n]||new Array(e).fill(null):new Array(e).fill(null),o=this.ops,i=o.length;for(let l=0;l<i;l++)r=o[l](r,t);return r}_evaluatePre(t,e,n){let r=this.colName,o=r&&r!=="*"?e[r]||new Array(n).fill(null):new Array(n).fill(null),i=this.ops,l=t!==void 0?t:i.length;for(let a=0;a<l;a++)o=i[a](o,e);return o}_evaluatePost(t,e,n){let r=this.ops,o=t!==void 0?t:r.length,i=e;for(let l=o;l<r.length;l++)i=r[l](i,n);return i}evaluatePrePartition(t,e){return this._evaluatePre(this.partitionOpsIndex,t,e)}evaluatePostPartition(t,e){return this._evaluatePost(this.partitionOpsIndex,t,e)}evaluatePreGrouping(t,e){return this._evaluatePre(this.groupingOpsIndex,t,e)}evaluatePostGrouping(t,e){return this._evaluatePost(this.groupingOpsIndex,t,e)}};var Wt=s=>class extends s{abs(){return g(this,_(t=>Math.abs(t)))}acos(){return g(this,_(t=>t<-1||t>1?null:Math.acos(t)))}acosh(){return g(this,_(t=>t<1?null:Math.acosh(t)))}add(t){return g(this,v(this,t,(e,n)=>e+n))}asin(){return g(this,_(t=>t<-1||t>1?null:Math.asin(t)))}asinh(){return g(this,_(Math.asinh))}atan(){return g(this,_(Math.atan))}atanh(){return g(this,_(t=>t<=-1||t>=1?null:Math.atanh(t)))}cbrt(){return g(this,_(Math.cbrt))}ceil(){return g(this,_(Math.ceil))}clip(t=null,e=null){return g(this,_(n=>t!==null&&e!==null?yt({val:n,min:t,max:e}):t!==null?Math.max(n,t):e!==null?Math.min(n,e):n))}cos(){return g(this,_(Math.cos))}cosh(){return g(this,_(Math.cosh))}degrees(){return g(this,_(t=>t*(180/Math.PI)))}div(t){return g(this,v(this,t,(e,n)=>n===0?null:e/n))}exp(){return g(this,_(Math.exp))}expm1(){return g(this,_(Math.expm1))}floor(){return g(this,_(Math.floor))}floordiv(t){return g(this,v(this,t,(e,n)=>n===0?null:Math.floor(e/n)))}hypot(t){return g(this,v(this,t,(e,n)=>Math.hypot(e,n)))}log(t=Math.E){return g(this,_(e=>e<=0?null:t===Math.E?Math.log(e):Math.log(e)/Math.log(t)))}log1p(){return g(this,_(t=>t<=-1?null:Math.log1p(t)))}mod(t){return g(this,v(this,t,(e,n)=>n===0?null:e%n))}mul(t){return g(this,v(this,t,(e,n)=>e*n))}negate(){return g(this,_(t=>-t))}pow(t){return g(this,v(this,t,(e,n)=>Math.pow(e,n)))}radians(){return g(this,_(t=>t*(Math.PI/180)))}rand(t,{min:e=0,max:n=1,integer:r=!1}={}){return g(this,o=>{let i=o.length,l=new Float64Array(i),a=t!==void 0?Me(t):Math.random,u=n-e;for(let c=0;c<i;c++){let f=a();l[c]=r?Math.floor(f*(u+1))+e:f*u+e}return l})}round(t=0){let e=Math.pow(10,t);return g(this,_(n=>Math.round(n*e)/e))}sign(){return g(this,_(Math.sign))}sin(){return g(this,_(Math.sin))}sinh(){return g(this,_(Math.sinh))}sqrt(){return g(this,_(t=>t<0?null:Math.sqrt(t)))}sub(t){return g(this,v(this,t,(e,n)=>e-n))}tan(){return g(this,_(Math.tan))}tanh(){return g(this,_(Math.tanh))}trunc(){return g(this,_(Math.trunc))}};function W(s){return s==null?s:s instanceof Date?`d:${s.getTime()}`:s instanceof Uint8Array?`u:${s.toString()}`:typeof s=="object"||typeof s=="function"?String(s):s}var qt=s=>class extends s{between(t,e,n="both"){return g(this,(r,o)=>{let i=r.length,l=this._resolve(t,o,i),a=this._resolve(e,o,i),u=new Array(i),c=C(l),f=C(a);for(let h=0;h<i;h++){let p=r[h],m=c?l[h]:l,y=f?a[h]:a;if(p==null||m==null||y==null)u[h]=null;else{let d=n==="both"||n==="left"?p>=m:p>m,b=n==="both"||n==="right"?p<=y:p<y;u[h]=d&&b}}return u})}eq(t){return g(this,v(this,t,(e,n)=>e===n))}eq_missing(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(C(o))for(let l=0;l<r;l++){let a=e[l],u=o[l];a==null&&u==null?i[l]=!0:a==null||u==null?i[l]=!1:i[l]=a===u}else for(let l=0;l<r;l++){let a=e[l];a==null&&o==null?i[l]=!0:a==null||o==null?i[l]=!1:i[l]=a===o}return i})}ge(t){return g(this,v(this,t,(e,n)=>e>=n))}gt(t){return g(this,v(this,t,(e,n)=>e>n))}has_nulls(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]==null)return!0;return!1})}is_close(t,e={}){let{abs_tol:n=1e-8,rel_tol:r=1e-8,nans_equal:o=!1}=e;return g(this,(i,l)=>{let a=i.length,u=this._resolve(t,l,a),c=C(u),f=new Array(a);for(let h=0;h<a;h++){let p=i[h],m=c?u[h]:u;if(p==null||m==null)f[h]=null;else if(Number.isNaN(p)||Number.isNaN(m))o&&Number.isNaN(p)&&Number.isNaN(m)?f[h]=!0:f[h]=!1;else if(!Number.isFinite(p)||!Number.isFinite(m))f[h]=p===m;else{let y=Math.abs(p-m),d=Math.max(r*Math.max(Math.abs(p),Math.abs(m)),n);f[h]=y<=d}}return f})}is_duplicated(){return g(this,t=>{let e=t.length,n=new Map,r=new Array(e);for(let i=0;i<e;i++){let l=W(t[i]);r[i]=l,n.set(l,(n.get(l)||0)+1)}let o=new Array(e);for(let i=0;i<e;i++)o[i]=(n.get(r[i])||0)>1;return o})}is_empty(t={}){let{ignoreNulls:e=!1}=t;return g(this,_(n=>{if(typeof n=="string")return n.length===0;if(C(n)){if(e){let r=n.length,o=0;for(let i=0;i<r;i++)n[i]!=null&&o++;return o===0}return n.length===0}return null}))}is_finite(){return g(this,_(Number.isFinite))}is_first_distinct(){return g(this,t=>{let e=t.length,n=new Set,r=new Array(e);for(let o=0;o<e;o++){let i=W(t[o]);n.has(i)?r[o]=!1:(n.add(i),r[o]=!0)}return r})}is_in(t){return g(this,(e,n)=>{let r=e.length,o=new Array(r);if(t&&typeof t=="object"&&"evaluate"in t){let i=t.evaluate(n,r);for(let l=0;l<r;l++){let a=e[l];if(a==null)o[l]=null;else{let u=i[l],c=new Set;if(C(u)){let f=u.length;for(let h=0;h<f;h++)c.add(W(u[h]))}else c.add(W(u));o[l]=c.has(W(a))}}}else{let i=C(t)?t:[],l=new Set,a=i.length;for(let u=0;u<a;u++)l.add(W(i[u]));for(let u=0;u<r;u++){let c=e[u];o[u]=c==null?null:l.has(W(c))}}return o})}is_infinite(){return g(this,_(t=>t===1/0||t===-1/0))}is_last_distinct(){return g(this,t=>{let e=t.length,n=new Set,r=new Array(e);for(let o=e-1;o>=0;o--){let i=W(t[o]);n.has(i)?r[o]=!1:(n.add(i),r[o]=!0)}return r})}is_n_distinct(t){return this._deriveAgg(e=>{let n=new Set,r=e.length;for(let o=0;o<r;o++)n.add(W(e[o]));return n.size===t})}is_nan(){return g(this,_(Number.isNaN))}is_not_nan(){return g(this,_(t=>!Number.isNaN(t)))}is_not_null(){return g(this,t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=t[r]!=null;return n})}is_null(){return g(this,t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=t[r]==null;return n})}is_unique(){return g(this,t=>{let e=t.length,n=new Map,r=new Array(e);for(let i=0;i<e;i++){let l=W(t[i]);r[i]=l,n.set(l,(n.get(l)||0)+1)}let o=new Array(e);for(let i=0;i<e;i++)o[i]=n.get(r[i])===1;return o})}le(t){return g(this,v(this,t,(e,n)=>e<=n))}lt(t){return g(this,v(this,t,(e,n)=>e<n))}ne(t){return g(this,v(this,t,(e,n)=>e!==n))}ne_missing(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(C(o))for(let l=0;l<r;l++){let a=e[l],u=o[l];a==null&&u==null?i[l]=!1:a==null||u==null?i[l]=!0:i[l]=a!==u}else for(let l=0;l<r;l++){let a=e[l];a==null&&o==null?i[l]=!1:a==null||o==null?i[l]=!0:i[l]=a!==o}return i})}not_in(t){return g(this,(e,n)=>{let r=e.length,o=new Array(r);if(t&&typeof t=="object"&&"evaluate"in t){let i=t.evaluate(n,r);for(let l=0;l<r;l++){let a=e[l];if(a==null)o[l]=null;else{let u=i[l],c=new Set;if(C(u)){let f=u.length;for(let h=0;h<f;h++)c.add(W(u[h]))}else c.add(W(u));o[l]=!c.has(W(a))}}}else{let i=C(t)?t:[],l=new Set,a=i.length;for(let u=0;u<a;u++)l.add(W(i[u]));for(let u=0;u<r;u++){let c=e[u];o[u]=c==null?null:!l.has(W(c))}}return o})}};var ut=class extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},V=class extends ut{},B=class extends V{constructor(t,e){super(e||`Column "${t}" does not exist in the DataFrame.`)}},ct=class extends ut{},nt=class extends ut{};var Ht=s=>class extends s{aggFn=this.aggFn||null;_deriveAgg(t){let e=g(this);return e.aggFn=t,e.groupingOpsIndex=this.ops.length,e.partitionOpsIndex=this.ops.length,e}all(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(!t[e])return!1;return!0})}all_null(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]!=null)return!1;return!0})}any(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e])return!0;return!1})}any_null(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]==null)return!0;return!1})}avg(){return this._deriveAgg(t=>{let e=0,n=0;for(let r=0;r<t.length;r++)t[r]!=null&&(e+=t[r],n++);return n?e/n:null})}count(t={}){return t.includeNulls?this._deriveAgg(e=>e.length):this._deriveAgg(e=>{let n=0;for(let r=0;r<e.length;r++)e[r]!=null&&n++;return n})}first(){return this._deriveAgg(t=>t[0]??null)}last(){return this._deriveAgg(t=>t[t.length-1]??null)}max(){return this._deriveAgg(t=>{let e=null;for(let n=0;n<t.length;n++)t[n]!=null&&(e===null||t[n]>e)&&(e=t[n]);return e})}mean(){return this.avg()}median(){return this._deriveAgg(t=>{let e=[];for(let o=0;o<t.length;o++)t[o]!=null&&e.push(t[o]);let n=e.length;if(!n)return null;e.sort((o,i)=>o-i);let r=Math.floor(n/2);return n%2!==0?e[r]:(e[r-1]+e[r])/2})}min(){return this._deriveAgg(t=>{let e=null;for(let n=0;n<t.length;n++)t[n]!=null&&(e===null||t[n]<e)&&(e=t[n]);return e})}mode(){return this._deriveAgg(t=>{let e=new Map,n=0,r=null;for(let o=0;o<t.length;o++){let i=t[o];if(i==null)continue;let l=(e.get(i)||0)+1;e.set(i,l),l>n&&(n=l,r=i)}return r})}n_unique(){return this._deriveAgg(t=>new Set(t).size)}quantile(t){if(t<0||t>1)throw new nt("Quantile q must be between 0 and 1");return this._deriveAgg(e=>{let n=[];for(let a=0;a<e.length;a++)e[a]!=null&&n.push(e[a]);let r=n.length;if(!r)return null;n.sort((a,u)=>a-u);let o=(r-1)*t,i=Math.floor(o),l=Math.ceil(o);return i===l?n[i]:n[i]+(o-i)*(n[l]-n[i])})}std(){return this._deriveAgg(t=>{let e=0,n=0;for(let i=0;i<t.length;i++)t[i]!=null&&(e+=t[i],n++);if(n<2)return 0;let r=e/n,o=0;for(let i=0;i<t.length;i++)t[i]!=null&&(o+=(t[i]-r)**2);return Math.sqrt(o/(n-1))})}sum(){return this._deriveAgg(t=>{let e=null;for(let n=0;n<t.length;n++)t[n]!=null&&(e=(e??0)+t[n]);return e})}};var Gt=s=>class extends s{partitionBy=this.partitionBy||null;_rolling(t,e){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let l=Math.max(0,i-t+1),a=i+1,u=r.slice(l,a);return e(u)},n}get isWindow(){return this.partitionBy!==null||this.evaluateWindow!==void 0||this.aggFn!==null}cum_count(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=0,l=t?o:0,a=t?n.length-1:o;for(let u=l;u<=a;u++)n[u]!=null&&i++;return i},e}cum_max(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=null,l=t?o:0,a=t?n.length-1:o;for(let u=l;u<=a;u++){let c=n[u];c!=null&&(i===null||c>i)&&(i=c)}return i},e}cum_min(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=null,l=t?o:0,a=t?n.length-1:o;for(let u=l;u<=a;u++){let c=n[u];c!=null&&(i===null||c<i)&&(i=c)}return i},e}cum_prod(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=1,l=!1,a=t?o:0,u=t?n.length-1:o;for(let c=a;c<=u;c++){let f=n[c];f!=null&&(i*=f,l=!0)}return l?i:null},e}cum_sum(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=0,l=t?o:0,a=t?n.length-1:o;for(let u=l;u<=a;u++){let c=n[u];c!=null&&(i+=c)}return i},e}dense_rank(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){let o=Array.from(new Set(e)).sort((a,u)=>a-u),i=new Map;for(let a=0;a<o.length;a++)i.set(o[a],a+1);let l=e[r];return i.get(l)??null},t}lag(t=1,e=null){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let l=e;return i-t>=0&&(l=r[i-t]),l},n}lead(t=1,e=null){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let l=e;return i+t<r.length&&(l=r[i+t]),l},n}over(t){let e=g(this),n=Array.isArray(t)?t:[t];return e.partitionBy=n,e}rank(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){let o=[...e].sort((a,u)=>a-u),i=new Map;for(let a=0;a<o.length;a++){let u=o[a];i.has(u)||i.set(u,a+1)}let l=e[r];return i.get(l)??null},t}rolling_max(t){return this._rolling(t,e=>{let n=null;for(let r=0;r<e.length;r++)e[r]!=null&&(n===null||e[r]>n)&&(n=e[r]);return n})}rolling_mean(t){return this._rolling(t,e=>{let n=0,r=0;for(let o=0;o<e.length;o++)e[o]!=null&&(n+=e[o],r++);return r?n/r:null})}rolling_median(t){return this._rolling(t,e=>{let n=[];for(let o=0;o<e.length;o++)e[o]!=null&&n.push(e[o]);if(!n.length)return null;n.sort((o,i)=>o-i);let r=Math.floor(n.length/2);return n.length%2!==0?n[r]:(n[r-1]+n[r])/2})}rolling_min(t){return this._rolling(t,e=>{let n=null;for(let r=0;r<e.length;r++)e[r]!=null&&(n===null||e[r]<n)&&(n=e[r]);return n})}rolling_quantile(t,e){return this._rolling(e,n=>{let r=[];for(let u=0;u<n.length;u++)n[u]!=null&&r.push(n[u]);let o=r.length;if(o===0)return null;r.sort((u,c)=>u-c);let i=t*(o-1),l=Math.floor(i),a=Math.ceil(i);return l===a?r[l]:r[l]+(i-l)*(r[a]-r[l])})}rolling_rank(t){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=Math.max(0,o-t+1),l=o+1,a=n.slice(i,l),u=n[o];if(u==null)return null;let c=[];for(let p=0;p<a.length;p++)a[p]!=null&&c.push(a[p]);if(c.length===0)return null;let f=[...c].sort((p,m)=>p-m),h=new Map;for(let p=0;p<f.length;p++){let m=f[p];h.has(m)||h.set(m,p+1)}return h.get(u)??null},e}rolling_std(t){return this._rolling(t,e=>{let n=0,r=0;for(let l=0;l<e.length;l++)e[l]!=null&&(n+=e[l],r++);if(r<2)return 0;let o=n/r,i=0;for(let l=0;l<e.length;l++)e[l]!=null&&(i+=(e[l]-o)**2);return Math.sqrt(i/(r-1))})}rolling_sum(t){return this._rolling(t,e=>{let n=null;for(let r=0;r<e.length;r++)e[r]!=null&&(n=(n??0)+e[r]);return n})}row_number(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){return r+1},t.outputName="row_number",t}};var Mt=class{constructor(t){this.expr=t}expr;_deriveString(t){return g(this.expr,_(e=>t(String(e))))}concat(t){return g(this.expr,v(this.expr,t,(e,n)=>String(e)+String(n)))}contains(t){return t==null?g(this.expr,e=>new Array(e.length).fill(null)):this._deriveString(e=>t instanceof RegExp?t.test(e):e.includes(t))}count_matches(t){return t==null?g(this.expr,e=>new Array(e.length).fill(null)):this._deriveString(e=>{if(t instanceof RegExp){let n=t.global?t:new RegExp(t.source,t.flags+"g"),r=e.match(n);return r?r.length:0}else{let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}})}decode_uri_component(){return this._deriveString(t=>{try{return decodeURIComponent(t)}catch{return t}})}encode_uri_component(){return this._deriveString(t=>{try{return encodeURIComponent(t)}catch{return t}})}ends_with(t){return this._deriveString(e=>e.endsWith(t))}explode(){return this._deriveString(t=>t.split(""))}extract(t,e=0){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>{let r=n.match(t);return r&&r[e]!==void 0?r[e]:null})}len(){return this.len_chars()}len_bytes(){return this._deriveString(t=>new TextEncoder().encode(t).length)}len_chars(){return this._deriveString(t=>t.length)}lower(){return this._deriveString(t=>t.toLowerCase())}lpad(t,e=" "){return this._deriveString(n=>n.padStart(t,e))}pad_end(t,e=" "){return this.rpad(t,e)}pad_start(t,e=" "){return this.lpad(t,e)}replace(t,e){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>n.replace(t,e))}replace_all(t,e){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>{if(t instanceof RegExp){let r=t.global?t:new RegExp(t.source,t.flags+"g");return n.replace(r,e)}return n.replaceAll(t,e)})}reverse(){return this._deriveString(t=>t.split("").reverse().join(""))}rpad(t,e=" "){return this._deriveString(n=>n.padEnd(t,e))}slice(t,e){return this._deriveString(n=>{let r=t<0?n.length+t:t,o=e!==void 0?r+e:void 0;return n.slice(r,o)})}slice_str(t,e){return this.slice(t,e)}split(t){return this._deriveString(e=>e.split(t))}starts_with(t){return this._deriveString(e=>e.startsWith(t))}strip_chars(t,e){return this._deriveString(n=>at(n,t,{mode:"both",...e}))}strip_chars_end(t,e){return this._deriveString(n=>at(n,t,{mode:"end",...e}))}strip_chars_start(t,e){return this._deriveString(n=>at(n,t,{mode:"start",...e}))}strip_prefix(t){return this._deriveString(e=>at(e,t,{mode:"start",maxScanStart:1,maxMatchesStart:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strip_suffix(t){return this._deriveString(e=>at(e,t,{mode:"end",maxScanEnd:1,maxMatchesEnd:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strptime(t,e=!0){return this._deriveString(n=>Pe(n,t,e))}to_date(){return this._deriveString(t=>{let e=Y(t);if(!e)return null;let n=new Date(e);return n.setUTCHours(0,0,0,0),n})}to_datetime(){return this._deriveString(Y)}to_decimal(t,e){return this._deriveString(n=>Ct(n,{precision:t,scale:e}))}to_integer(){return this._deriveString(t=>H(t))}to_lowercase(){return this.lower()}to_time(){return this._deriveString(t=>{let e=Y(t);if(e)return e.toISOString().split("T")[1].slice(0,12);let n=t.trim();if(St.test(n)){let r=new Date(`1970-01-01T${n}${kt.test(n)?"":"Z"}`);if(z(r))return r.toISOString().split("T")[1].slice(0,12)}return null})}to_titlecase(){return this._deriveString(t=>t.replace(/\b\w/g,e=>e.toUpperCase()))}to_uppercase(){return this.upper()}trim(){return this.strip_chars()}trim_end(){return this.strip_chars_end()}trim_start(){return this.strip_chars_start()}upper(){return this._deriveString(t=>t.toUpperCase())}zfill(t){return this._deriveString(e=>e.padStart(t,"0"))}},zt=s=>class extends s{get str(){return new Mt(this)}};var Yt=s=>class extends s{and(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=C(o),l=new Array(r);for(let a=0;a<r;a++){let u=e[a],c=i?o[a]:o;u===!1||c===!1?l[a]=!1:u==null||c==null?l[a]=null:l[a]=!0}return l})}not(){return g(this,_(t=>!t))}or(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=C(o),l=new Array(r);for(let a=0;a<r;a++){let u=e[a],c=i?o[a]:o;u===!0||c===!0?l[a]=!0:u==null||c==null?l[a]=null:l[a]=!1}return l})}xor(t){return g(this,v(this,t,(e,n)=>!!e!=!!n))}};var Ut=class{constructor(t){this.expr=t}expr;_deriveDate(t){return g(this.expr,_(e=>{let n=Y(e);return n?t(n):null}))}_deriveDuration(t){return g(this.expr,_(e=>typeof e=="number"?t(e):null))}century(){return this._deriveDate(Ne)}date(){return this._deriveDate(t=>new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())))}datetime(){return this._deriveDate(t=>t)}day(){return this._deriveDate(t=>t.getUTCDate())}epoch(t="ms"){return this._deriveDate(e=>Fe(e,t))}hour(){return this._deriveDate(t=>t.getUTCHours())}is_leap_year(){return this._deriveDate(Ke)}microsecond(){return this._deriveDate(t=>t.getUTCMilliseconds()*Et)}millennium(){return this._deriveDate(je)}millisecond(){return this._deriveDate(t=>t.getUTCMilliseconds())}minute(){return this._deriveDate(t=>t.getUTCMinutes())}month(){return this._deriveDate(t=>t.getUTCMonth()+1)}month_end(){return this._deriveDate(t=>Kt(t,1,0))}month_start(){return this._deriveDate(t=>Kt(t,0,1))}nanosecond(){return this._deriveDate(t=>t.getUTCMilliseconds()*Ot)}ordinal_day(){return this._deriveDate(Ve)}quarter(){return this._deriveDate(Be)}second(){return this._deriveDate(t=>t.getUTCSeconds())}strftime(t,e){return this._deriveDate(n=>$e(n,t,e))}time(){return this._deriveDate(t=>t.toISOString().split("T")[1].slice(0,12))}timestamp(t="ms"){return this.epoch(t)}to_string(t,e){return this.strftime(t,e)}total_days(){return this._deriveDuration(t=>t/dt)}total_hours(){return this._deriveDuration(t=>t/Re)}total_microseconds(){return this._deriveDuration(t=>t*Et)}total_milliseconds(){return this._deriveDuration(t=>t)}total_minutes(){return this._deriveDuration(t=>t/ve)}total_nanoseconds(){return this._deriveDuration(t=>t*Ot)}total_seconds(){return this._deriveDuration(t=>t/Bt)}week(){return this._deriveDate(Le)}weekday(){return this._deriveDate(t=>t.getUTCDay()||7)}year(){return this._deriveDate(t=>t.getUTCFullYear())}},Zt=s=>class extends s{get dt(){return new Ut(this)}};var vt=class{constructor(t){this.expr=t}expr;_deriveList(t){return g(this.expr,_(e=>C(e)?t(e):null))}all(){return this._deriveList(t=>{let e=Array.from(t);for(let n=0;n<e.length;n++)if(!e[n])return!1;return!0})}any(){return this._deriveList(t=>{let e=Array.from(t);for(let n=0;n<e.length;n++)if(e[n])return!0;return!1})}contains(t){return this._deriveList(e=>Array.from(e).includes(t))}contains_all(t){return this._deriveList(e=>{let n=Array.from(e);for(let r=0;r<t.length;r++)if(!n.includes(t[r]))return!1;return!0})}contains_any(t){return this._deriveList(e=>{let n=Array.from(e);for(let r=0;r<t.length;r++)if(n.includes(t[r]))return!0;return!1})}count_matches(t){return this._deriveList(e=>{let n=Array.from(e),r=0;for(let o of n)o===t&&r++;return r})}drop_nulls(){return this._deriveList(t=>{let e=Array.from(t),n=[];for(let r=0;r<e.length;r++)e[r]!=null&&n.push(e[r]);return n})}first(t=!0){return this.get(0,t)}gather(t,e=!0){let n=Array.isArray(t)?t:[t];return this._deriveList(r=>{let o=r.length,i=new Array(n.length);for(let l=0;l<n.length;l++){let a=n[l],u=r.at(a);if(u===void 0&&!e)throw new nt(`Index ${a} is out of bounds for list of length ${o}`);i[l]=u??null}return i})}gather_every(t,e=0){if(t<=0)throw new nt("Step size n must be positive");return this._deriveList(n=>{let r=n.length,o=[];for(let i=e;i<r;i+=t)o.push(n[i]);return o})}get(t,e=!0){return this._deriveList(n=>{let r=n.at(t);if(r===void 0&&!e)throw new nt(`Index ${t} is out of bounds for list of length ${n.length}`);return r??null})}join(t,{ignoreNulls:e=!1}={}){return this._deriveList(n=>{let r=Array.from(n),o=[];for(let i=0;i<r.length;i++){let l=r[i];l!=null?o.push(String(l)):e||o.push("")}return o.join(t)})}last(t=!0){return this.get(-1,t)}len(){return this.lengths()}lengths(){return this._deriveList(t=>t.length)}max(){return this._deriveList(t=>bt(t).max)}mean(){return this._deriveList(t=>{let{sum:e,count:n}=bt(t);return e!==null&&n>0?e/n:null})}median(){return this._deriveList(He)}min(){return this._deriveList(t=>bt(t).min)}mode(){return this._deriveList(Ge)}n_unique(){return this._deriveList(t=>new Set(Array.from(t)).size)}reverse(){return this._deriveList(t=>Array.from(t).reverse())}slice(t,e){return this._deriveList(n=>{let r=Array.from(n),o=t<0?Math.max(0,r.length+t):t,i=e!==void 0?o+e:r.length;return r.slice(o,i)})}sort(t=!1){return this._deriveList(e=>$t(e,t))}sum(){return this._deriveList(t=>bt(t).sum)}unique(){return this._deriveList(t=>Array.from(new Set(Array.from(t))))}},Xt=s=>class extends s{get list(){return new vt(this)}};var ze=s=>class extends s{fill_null(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(C(o))for(let l=0;l<r;l++){let a=e[l];i[l]=a??o[l]}else for(let l=0;l<r;l++){let a=e[l];i[l]=a??o}return i})}reverse(){return g(this,t=>t.slice().reverse())}};var k=class extends Xt(Zt(Yt(zt(Gt(Ht(qt(Wt(ze(wt))))))))){colName;excludedCols=[];constructor(t){super(),this.colName=String(t),this.outputName=this.colName}};function it(s){let t=new k(Pt);return t.isLiteral=!0,t.literalValue=s,t.ops.push(e=>{let n=e.length,r=new Array(n);for(let o=0;o<n;o++)r[o]=s;return r}),t}function Jt(){return new k("*")}function Qt(s){let t=new k("*");return t.excludedCols=Array.isArray(s)?s:[s],t}function te(...s){let t=s.length===1&&Array.isArray(s[0])?s[0]:s,e=new k("*coalesce*");return e.ops.push((n,r)=>{let o=n.length,l=t.map(c=>typeof c=="string"?new k(c):c&&typeof c=="object"&&"evaluate"in c?c:it(c)).map(c=>c.evaluate(r,o)),a=new Array(o),u=l.length;for(let c=0;c<o;c++){let f=null;for(let h=0;h<u;h++){let p=l[h][c];if(p!=null){f=p;break}}a[c]=f}return a}),e}var Rt=class{predicates;values;constructor(t,e){this.predicates=t,this.values=e}then(t){return new _t(this.predicates,this.values.concat(t))}},Ft=class{predicates;constructor(t){this.predicates=[t]}then(t){return new _t(this.predicates,[t])}},_t=class s extends k{predicates;values;otherwiseValue;constructor(t,e,n=null){super(typeof t=="string"?t:"*when*"),this.predicates=Array.isArray(t)?t:[],this.values=e||[],this.otherwiseValue=n,this.ops.push((r,o)=>{let i=r.length,l=d=>typeof d=="string"?d in o?new k(d):it(d):d&&typeof d=="object"&&"evaluate"in d?d:it(d),a=this.predicates.map(l),u=this.values.map(l),c=l(this.otherwiseValue),f=a.map(d=>d.evaluate(o,i)),h=u.map(d=>d.evaluate(o,i)),p=c.evaluate(o,i),m=new Array(i),y=f.length;for(let d=0;d<i;d++){let b=!1;for(let w=0;w<y;w++)if(f[w][d]===!0){m[d]=h[w][d],b=!0;break}b||(m[d]=p[d])}return m})}when(t){return new Rt(this.predicates.concat(t),this.values)}otherwise(t){return new s(this.predicates,this.values,t)}};function ee(s){return new Ft(s)}function ft(s,t,e){let n=[],r=e?new Set(e):new Set;for(let o of s)if(typeof o=="string")n.push(new k(o));else if(o instanceof k&&o.colName==="*"){let i=new Set(o.excludedCols);for(let l of t)if(!r.has(l)&&!i.has(l)){let a=new k(l);a.ops=[...o.ops],a.aggFn=o.aggFn,a.partitionOpsIndex=o.partitionOpsIndex,a.groupingOpsIndex=o.groupingOpsIndex,a.partitionBy=o.partitionBy,o.evaluateWindow&&(a.evaluateWindow=o.evaluateWindow),o.outputName&&o.outputName!=="*"&&(a.outputName=o.outputName),n.push(a)}}else if(o&&typeof o=="object"&&"evaluate"in o&&!o.colName){for(let i of t)if(!r.has(i)){let l=new k(i);l.ops=[...o.ops],l.aggFn=o.aggFn,l.groupingOpsIndex=o.groupingOpsIndex,l.partitionOpsIndex=o.partitionOpsIndex,n.push(l)}}else n.push(o);return n}var K=class{get isNumeric(){return!1}get isInteger(){return!1}get isFloat(){return!1}get isSigned(){return!1}get isUnsigned(){return!1}get isTemporal(){return!1}get isNested(){return!1}get isBoolean(){return!1}get isString(){return!1}get isUtf8(){return!1}get isObject(){return!1}get isNull(){return!1}get isBinary(){return!1}},ht=class extends K{get isNumeric(){return!0}},Nt=class extends ht{get isInteger(){return!0}},X=class extends Nt{get isSigned(){return!0}},J=class extends Nt{get isUnsigned(){return!0}},mt=class extends ht{get isFloat(){return!0}},Q=class extends K{get isTemporal(){return!0}},pt=class extends K{get isNested(){return!0}};var ne=class extends X{name="Int8";coerce(t){return H(t,"Int8")}equals(t){return t.name==="Int8"}allocate(t){return new Int8Array(t)}},Ye=new ne;var re=class extends X{name="Int16";coerce(t){return H(t,"Int16")}equals(t){return t.name==="Int16"}allocate(t){return new Int16Array(t)}},Ze=new re;var oe=class extends X{name="Int32";coerce(t){return H(t)}equals(t){return t.name==="Int32"}allocate(t){return new Int32Array(t)}},Xe=new oe;var se=class extends X{name="Int64";coerce(t){return It(t)}equals(t){return t.name==="Int64"}allocate(t){return new BigInt64Array(t)}},Je=new se;var ie=class extends J{name="UInt8";coerce(t){return H(t,"UInt8")}equals(t){return t.name==="UInt8"}allocate(t){return new Uint8Array(t)}},Qe=new ie;var le=class extends J{name="UInt16";coerce(t){return H(t,"UInt16")}equals(t){return t.name==="UInt16"}allocate(t){return new Uint16Array(t)}},tn=new le;var ae=class extends J{name="UInt32";coerce(t){return H(t,"UInt32")}equals(t){return t.name==="UInt32"}allocate(t){return new Uint32Array(t)}},en=new ae;var ue=class extends J{name="UInt64";coerce(t){return It(t)}equals(t){return t.name==="UInt64"}allocate(t){return new BigUint64Array(t)}},nn=new ue;var ce=class extends mt{name="Float32";coerce(t){return At(t,"Float32")}equals(t){return t.name==="Float32"}allocate(t){return new Float32Array(t)}},rn=new ce;var fe=class extends mt{name="Float64";coerce(t){return At(t)}equals(t){return t.name==="Float64"}allocate(t){return new Float64Array(t)}},on=new fe;var Lt=class s extends ht{constructor(e,n){super();this.precision=e;this.scale=n;this.name=e!==void 0&&n!==void 0?`Decimal(${e}, ${n})`:"Decimal"}precision;scale;name;coerce(e){return Ct(e,{precision:this.precision,scale:this.scale})}equals(e){return e instanceof s&&this.precision===e.precision&&this.scale===e.scale}allocate(e){return new Array(e).fill(null)}};var he=class extends K{name="Boolean";get isBoolean(){return!0}coerce(t){return t==null?null:!!t}equals(t){return t.name==="Boolean"}allocate(t){return new Array(t).fill(null)}},sn=new he;var me=class extends K{name="Utf8";get isString(){return!0}get isUtf8(){return!0}coerce(t){return t==null?null:String(t)}equals(t){return t.name==="Utf8"}allocate(t){return new Array(t).fill(null)}},ln=new me;var pe=class extends K{name="Binary";get isBinary(){return!0}coerce(t){return qe(t)}equals(t){return t.name==="Binary"}allocate(t){return new Array(t).fill(null)}},an=new pe;var ge=class extends Q{name="Date";coerce(t){let e=Y(t);return e?(e.setUTCHours(0,0,0,0),e):null}equals(t){return t.name==="Date"}allocate(t){return new Array(t).fill(null)}},un=new ge;var ye=class extends Q{name="Datetime";coerce(t){return Y(t)}equals(t){return t.name==="Datetime"}allocate(t){return new Array(t).fill(null)}},cn=new ye;var de=class extends Q{name="Time";coerce(t){if(t==null)return null;if(typeof t=="string"){let n=t.trim();if(St.test(n)){let r=new Date(`1970-01-01T${n}${kt.test(n)?"":"Z"}`);if(z(r))return r.toISOString().split("T")[1].slice(0,12)}}let e=Y(t);return e?e.toISOString().split("T")[1].slice(0,12):null}equals(t){return t.name==="Time"}allocate(t){return new Array(t).fill(null)}},fn=new de;var xe=class extends Q{name="Duration";coerce(t){return et(t)}equals(t){return t.name==="Duration"}allocate(t){return new Array(t).fill(null)}},hn=new xe;var be=class extends K{name="Object";get isObject(){return!0}coerce(t){return t===void 0?null:t}equals(t){return t.name==="Object"}allocate(t){return new Array(t).fill(null)}},mn=new be;var we=class extends K{name="Null";get isNull(){return!0}coerce(t){return null}equals(t){return t.name==="Null"}allocate(t){return new Array(t).fill(null)}},pn=new we;var _e=class s extends pt{constructor(e){super();this.innerType=e}innerType;name="List";coerce(e){if(e==null)return null;let n=C(e)?Array.from(e):[e],r=n.length,o=new Array(r);for(let i=0;i<r;i++)o[i]=this.innerType.coerce(n[i]);return o}equals(e){return e instanceof s&&this.innerType.equals(e.innerType)}allocate(e){return new Array(e).fill(null)}},gn=s=>new _e(s);var Te=class s extends pt{constructor(e){super();this.fields=e}fields;name="Struct";coerce(e){if(!Z(e))return null;let n={};for(let[r,o]of Object.entries(this.fields))n[r]=o.coerce(e[r]);return n}equals(e){if(!(e instanceof s))return!1;let n=Object.keys(this.fields),r=Object.keys(e.fields);if(n.length!==r.length)return!1;for(let o of n)if(!e.fields[o]||!this.fields[o].equals(e.fields[o]))return!1;return!0}allocate(e){return new Array(e).fill(null)}},yn=s=>new Te(s);var L={Int8:Ye,Int16:Ze,Int32:Xe,Int64:Je,UInt8:Qe,UInt16:tn,UInt32:en,UInt64:nn,Float32:rn,Float64:on,Decimal:(s,t)=>new Lt(s,t),Boolean:sn,Utf8:ln,Binary:an,Date:un,Datetime:cn,Time:fn,Duration:hn,Object:mn,Null:pn,List:gn,Struct:yn};function kn(s,t,e){let n=new Map,r=e.length,o=new Array(r);for(let i=0;i<r;i++){let l=e[i];if(typeof l=="string"){if(!(l in s))throw new B(l,`Partition key "${l}" does not exist in the DataFrame.`);o[i]=s[l]}else o[i]=l.evaluate(s,t)}for(let i=0;i<t;i++){let l=new Array(o.length);for(let c=0;c<o.length;c++){let f=o[c][i];l[c]=f==null?"":String(f)}let a=l.join("\0"),u=n.get(a);u===void 0&&(u=[],n.set(a,u)),u.push(i)}return n}function jt(s,t,e){let n=new Array(e);if(e===0)return n;let r=s.partitionBy||[],o=kn(t,e,r),i=s.evaluatePrePartition(t,e);for(let l of o.values()){let a=l.length,u=new Array(a);for(let c=0;c<a;c++)u[c]=i[l[c]];if(s.evaluateWindow){for(let c=0;c<a;c++)n[l[c]]=s.evaluateWindow(u,l,c);continue}if(s.aggFn){let c=s.aggFn(u);for(let f=0;f<a;f++)n[l[f]]=c;continue}for(let c=0;c<a;c++)n[l[c]]=i[l[c]]}return s.evaluatePostPartition(n,t)}function De(s){if(!Array.isArray(s)||s.length===0)return{columns:{},height:0};let t=s.length,e=new Set;for(let o=0;o<t;o++){let i=s[o];if(Z(i)){let l=Object.keys(i);for(let a=0;a<l.length;a++)e.add(l[a])}}let n=Array.from(e),r={};for(let o=0;o<n.length;o++)r[n[o]]=new Array(t);for(let o=0;o<t;o++){let i=s[o]||{};for(let l=0;l<n.length;l++){let a=n[l],u=i[a];r[a][o]=u===void 0?null:u}}return{columns:r,height:t}}function Ae(s,t){let e=Object.keys(s),n=new Array(t);for(let r=0;r<t;r++){let o={};for(let i=0;i<e.length;i++){let l=e[i],a=s[l][r];o[l]=a===void 0?null:a}n[r]=o}return n}function En(s,t,e){let n={};for(let r=0;r<e.length;r++){let o=e[r],i=s[o][t];n[o]=i===void 0?null:i}return n}function rt(s){if(s.length===0)return L.Utf8;let t=!0,e=!0,n=!0,r=!0,o=!0,i=!0,l=!1,a=!1,u=[];for(let c=0;c<s.length;c++){let f=s[c];if(f!=null){if(a=!0,!Array.isArray(f))i=!1;else for(let h=0;h<f.length;h++)u.push(f[h]);f instanceof Date&&(l=!0),typeof f!="boolean"&&(t=!1),typeof f!="bigint"&&(r=!1),typeof f!="number"?(n=!1,e=!1):Number.isInteger(f)||(e=!1),!(f instanceof Date)&&(typeof f!="string"||isNaN(Date.parse(f)))&&(o=!1)}}if(!a)return L.Utf8;if(i){let c=rt(u);return L.List(c)}if(t)return L.Boolean;if(r)return L.Int64;if(n&&!e)return L.Float64;if(n&&e){let c=!0;for(let f=0;f<s.length;f++){let h=s[f];if(h!=null&&(h<-2147483648||h>2147483647)){c=!1;break}}return c?L.Int32:L.Float64}return o&&l?L.Datetime:L.Utf8}var Tt=class{groups;keys;allKeys;parentColumns;parentHeight;parentSchema;constructor(t,e,n,r,o,i){this.groups=t,this.keys=e,this.allKeys=n,this.parentColumns=r,this.parentHeight=o,this.parentSchema=i}to_dataframe(){let t=this.keys.length,e=new Array(t);for(let l=0;l<t;l++)e[l]=String(this.keys[l]);let n=this.groups.size,r={};for(let l=0;l<e.length;l++)r[e[l]]=new Array(n);let o=0;for(let l of this.groups.values()){if(l.length===0)continue;let a=l[0];for(let u=0;u<e.length;u++){let c=e[u],f=this.parentColumns[c][a];r[c][o]=f===void 0?null:f}o++}let i={};for(let l of e)i[l]=this.parentSchema[l];return new F(r,i,o)}agg(...t){let e=this.allKeys.length,n=new Array(e);for(let f=0;f<e;f++)n[f]=String(this.allKeys[f]);let r=this.keys.length,o=new Array(r);for(let f=0;f<r;f++)o[f]=String(this.keys[f]);let i=ft(t.flat(),n,o),l=this.groups.size,a={};for(let f=0;f<o.length;f++)a[o[f]]=new Array(l);let u=0;for(let f of this.groups.values()){if(f.length===0)continue;let h=f[0];for(let p=0;p<o.length;p++){let m=o[p],y=this.parentColumns[m][h];a[m][u]=y===void 0?null:y}u++}for(let f=0;f<i.length;f++){let h=i[f],p=h.outputName||h.colName||"*";if(!h.aggFn){a[p]=h.evaluate(a,l);continue}let m=h.evaluatePreGrouping(this.parentColumns,this.parentHeight),y=new Array(l),d=0;for(let b of this.groups.values()){if(b.length===0)continue;let w=new Array(b.length);for(let A=0;A<b.length;A++)w[A]=m[b[A]];y[d]=h.aggFn(w),d++}a[p]=h.evaluatePostGrouping(y,a)}let c={};for(let f of o)c[f]=this.parentSchema[f];for(let f of i){let h=f.outputName||f.colName||"*";c[h]=rt(a[h])}return new F(a,c,u)}};function dn(s,t,e){if(s==null)throw new V(`Invalid input to ${t} at index ${e}: item cannot be null or undefined.`);if(s instanceof F)return[s];if(xt(s))return[new F(s)];if(C(s)){if(lt(s,F,{mode:"every"}))return s;if(lt(s,"plainObject",{mode:"every"}))return[new F(s)];let n=lt(s,F,{mode:"some"});for(let r=0;r<s.length;r++)if(n?!(s[r]instanceof F):!xt(s[r]))throw new V(n?`Invalid input to ${t} at index ${e}, sub-index ${r}: nested array must contain only DataFrame instances.`:`Invalid input to ${t} at index ${e}, row ${r}: rows must be plain objects.`)}throw new V(`Invalid input to ${t} at index ${e}: expected DataFrame, row array, or column dictionary.`)}function Dt(s,t={}){if(s==null)throw new V("Invalid input to concat: rawItems cannot be null or undefined.");let e=Array.isArray(s)?s:[s],n=[];for(let i=0;i<e.length;i++)n.push(...dn(e[i],"concat",i));let{how:r="vertical"}=t,o=t.horizontal?.strict??!0;if(n.length===0)return new F({},{},0);if(n.length===1&&r!=="horizontal")return n[0];switch(r){case"vertical":{let i=[];for(let p=0;p<n.length;p++)n[p].height>0&&i.push(n[p]);if(i.length===0)return new F({},{},0);let l=i[0],a=Object.keys(l._columns);for(let p=0;p<n.length;p++){let m=n[p];if(m.height===0)continue;let y=Object.keys(m._columns);if(a.length!==y.length)throw new V(`[Strict Vertical] Column count mismatch at index ${p}.`);for(let d=0;d<a.length;d++){if(a[d]!==y[d])throw new V(`[Strict Vertical] Schema mismatch at position ${d} in DF ${p}. Expected column "${a[d]}", but found "${y[d]}".`);let b=l.schema[a[d]],w=m.schema[a[d]];if(b&&w&&!b.equals(w))throw new ct(`[Strict Type Check] Schema type mismatch for column "${a[d]}": expected ${b.name}, found ${w.name}.`)}}let u=0;for(let p of n)u+=p.height;let c=n.find(p=>p.height>0)?.schema||n[0]?.schema||{},f={};for(let p of a){let m=c[p],y=!1;for(let b of n){let w=b._columns[p];if(!w){y=!0;break}if(!P(w)){for(let A=0;A<w.length;A++)if(w[A]==null){y=!0;break}}if(y)break}let d=m&&m.allocate?m.allocate(u):new Array(u).fill(null);y&&P(d)&&(d=new Array(u).fill(null)),f[p]=d}let h=0;for(let p of n){let m=p.height;if(m!==0){for(let y of a){let d=p._columns[y]||new Array(m).fill(null),b=f[y];if(P(b)&&P(d))b.set(d,h);else{let w=b;for(let A=0;A<m;A++)w[h+A]=d[A]}}h+=m}}return new F(f,c,u)}case"horizontal":{let i=n[0].height;for(let c=1;c<n.length;c++)n[c].height>i&&(i=n[c].height);let l=new Set;for(let c=0;c<n.length;c++){let f=n[c];if(o&&f.height!==i)throw new V(`[Horizontal] Row count mismatch at index ${c}. Expected ${i}, got ${f.height}. Set strict=false to allow padding.`);for(let h of Object.keys(f._columns)){if(l.has(h))throw new V(`[Horizontal] Duplicate column name "${h}" detected. Horizontal concat requires unique names.`);l.add(h)}}let a={},u={};for(let c of n){let f=c.height;Object.assign(u,c.schema);for(let[h,p]of Object.entries(c._columns))if(f===i)a[h]=P(p)?Array.from(p):p;else{let m=new Array(i);for(let y=0;y<f;y++)m[y]=p[y];for(let y=f;y<i;y++)m[y]=null;a[h]=m}}return new F(a,u,i)}case"diagonal":{let i=new Set;for(let h of n)for(let p of Object.keys(h._columns))i.add(p);let l=Array.from(i),a=0;for(let h=0;h<n.length;h++)a+=n[h].height;let u={};for(let h of l){let p=null;for(let m of n){let y=m.schema[h];if(y){if(p===null)p=y;else if(!p.equals(y))throw new ct(`[Strict Type Check] Schema type mismatch for column "${h}": expected ${p.name}, found ${y.name}.`)}}u[h]=p||L.Utf8}let c={};for(let h=0;h<l.length;h++)c[l[h]]=new Array(a).fill(null);let f=0;for(let h=0;h<n.length;h++){let p=n[h],m=p.height;if(m!==0){for(let y=0;y<l.length;y++){let d=l[y],b=c[d],w=p._columns[d];if(w!==void 0)if(P(w)&&P(b))b.set(w,f);else{let A=b;for(let S=0;S<m;S++)A[f+S]=w[S]}else{let A=b;for(let S=0;S<m;S++)A[f+S]=null}}f+=m}}return new F(c,u,a)}}}var F=class s{_columns;_height;_schema={};constructor(t,e,n){if(Array.isArray(t)){let{columns:r,height:o}=De(t);this._columns=r,this._height=o,e?this.applySchema(e):this.inferSchema();return}if(Z(t)){let r=-1;for(let[o,i]of Object.entries(t)){let l=C(i)?i.length:0;if(r===-1)r=l;else if(l!==r)throw new V(`Column height mismatch: Column "${o}" has length ${l}, but previous columns have length ${r}`)}this._columns=t,this._height=n!==void 0?n:r===-1?0:r,e?this.applySchema(e):this.inferSchema();return}this._columns={},this._height=0,e?this.applySchema(e):this._schema={}}inferSchema(){let t={},e=Object.keys(this._columns);for(let n of e)t[n]=rt(this._columns[n]);this._schema=t}applySchema(t){this._schema=t;let e=Object.keys(t),n={};for(let r of e){let o=t[r],i=this._columns[r],l=o.allocate?o.allocate(this._height):new Array(this._height).fill(null);if(!i){this._height>0&&P(l)&&(l=new Array(this._height).fill(null)),n[r]=l;continue}let a=!1,u=new Array(this._height);for(let c=0;c<this._height;c++){let f=o.coerce(i[c]);u[c]=f,f==null&&(a=!0)}a&&P(l)&&(l=new Array(this._height));for(let c=0;c<this._height;c++)l[c]=u[c];n[r]=l}this._columns=n}getSchema(){return this._schema}to_dicts(){return Ae(this._columns,this._height)}to_dict(){return{...this._columns}}get columns(){return Object.keys(this._columns)}concat(t,e={}){let n=lt(t,s,{mode:"every",allowEmpty:!1})?t:[t];return Dt([this,...n],e)}drop(...t){let e=new Set(t.flat()),n={},r={};for(let o of Object.keys(this._columns))e.has(o)||(n[o]=this._columns[o],r[o]=this._schema[o]);return new s(n,r,this._height)}get dtypes(){let t=Object.keys(this._columns),e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=this._schema[t[r]];return n}filter(...t){if(this._height===0)return new s({},this._schema,0);let e=this._height,n=Object.keys(this._columns),r=n.length,o=[],i=[];for(let h of t)typeof h=="function"?i.push(h):o.push(h.evaluate(this._columns,e));let l=[],a=0,u=null;if(i.length>0){let h=this._columns;u={};for(let p=0;p<r;p++){let m=n[p],y=h[m];Object.defineProperty(u,m,{get(){let d=y[a];return d===void 0?null:d},enumerable:!0,configurable:!0})}}for(let h=0;h<e;h++){let p=!0;for(let m=0;m<o.length;m++)if(!o[m][h]){p=!1;break}if(p){if(u){a=h;for(let m=0;m<i.length;m++)if(!i[m](u)){p=!1;break}}p&&l.push(h)}}let c=l.length,f={};for(let h=0;h<r;h++){let p=n[h],m=this._columns[p],y=new Array(c);for(let d=0;d<c;d++)y[d]=m[l[d]];f[p]=y}return new s(f,this._schema,c)}groupby(t){let e=st(t),n=new Map,r=this._height,o=e.length,i=new Array(o);for(let c=0;c<o;c++)i[c]=String(e[c]);for(let c=0;c<i.length;c++)if(!(i[c]in this._columns))throw new B(i[c],`Grouping key "${i[c]}" does not exist`);let l=o===1?i[0]:null,a=l?this._columns[l]:null;for(let c=0;c<r;c++){let f;if(l){let p=a[c];f=p==null?"":String(p)}else{let p=new Array(o);for(let m=0;m<o;m++){let y=this._columns[i[m]][c];p[m]=y==null?"":String(y)}f=p.join("\0")}let h=n.get(f);h===void 0&&n.set(f,h=[]),h.push(c)}let u=Object.keys(this._columns);return new Tt(n,e,u,this._columns,this._height,this._schema)}head(t=10){return this.limit(t,{offset:0,from:"start"})}get height(){return this._height}hstack(t,e={}){return this.concat(t,{how:"horizontal",horizontal:e})}join(t){let{other:e,on:n,how:r="inner",suffixes:o=["","_right"]}=t,i=st(n);for(let T of i){let D=String(T);if(!(D in this._columns))throw new B(D,`Join key "${D}" does not exist in the left DataFrame.`);if(!(D in e._columns))throw new B(D,`Join key "${D}" does not exist in the right DataFrame.`)}let[l,a]=o,u=Object.keys(this._columns),c=Object.keys(e._columns),f=new Set(i),h=u.length,p=c.length,m=(T,D)=>{let O=i.length;if(O===1){let M=T[i[0]][D];return M==null?null:String(M)}let R=new Array(O);for(let M=0;M<O;M++){let q=T[i[M]][D];if(q==null)return null;R[M]=String(q)}return R.join("\0")},y=new Map,d=e._height,b=e._columns;for(let T=0;T<d;T++){let D=m(b,T);if(D===null)continue;let O=y.get(D);O===void 0&&(O=[],y.set(D,O)),O.push(T)}let w=this._height,A=this._columns,S=[],x=[],I=r==="outer"||r==="right",U=I?new Set:null;for(let T=0;T<w;T++){let D=m(A,T),O=D===null?void 0:y.get(D);if(O===void 0)(r==="left"||r==="outer")&&(S.push(T),x.push(null));else for(let R=0;R<O.length;R++){let M=O[R];I&&U.add(M),S.push(T),x.push(M)}}if(I)for(let T=0;T<d;T++)U.has(T)||(S.push(-1),x.push(T));let E=S.length,N={},$={};for(let T=0;T<h;T++){let D=u[T],O=D in e._columns&&!f.has(D)?`${D}${l}`:D,R=this._columns[D],M=f.has(D),q=new Array(E);if(M){let G=e._columns[D];for(let tt=0;tt<E;tt++){let Ie=S[tt];if(Ie!==-1)q[tt]=R[Ie];else{let Ce=x[tt];q[tt]=Ce!==null?G[Ce]:null}}}else for(let G=0;G<E;G++){let tt=S[G];q[G]=tt!==-1?R[tt]:null}N[O]=q,this._schema[D]&&($[O]=this._schema[D])}for(let T=0;T<p;T++){let D=c[T];if(!f.has(D)){let O=D in this._columns?`${D}${a}`:D,R=e._columns[D],M=new Array(E);for(let q=0;q<E;q++){let G=x[q];M[q]=G!==null?R[G]:null}N[O]=M,e._schema[D]&&($[O]=e._schema[D])}}return new s(N,$,E)}limit(t,e={}){let{offset:n=0,from:r="start"}=e,o=this._height,i=isNaN(t)?0:Math.max(Math.floor(t),0),l=isNaN(n)?0:Math.max(Math.floor(n),0);if(i===0||o===0||l>=o){let h={},p={};for(let m of Object.keys(this._columns))h[m]=[],p[m]=this._schema[m];return new s(h,p,0)}let a=0,u=0;r==="end"?(u=Math.max(o-l,0),a=Math.max(u-i,0)):(u=Math.min(l+i,o),a=l);let c=Math.max(u-a,0),f={};for(let h of Object.keys(this._columns))f[h]=this._columns[h].slice(a,u);return new s(f,this._schema,c)}pivot(t){if(this._height===0)return new s({},{},0);let{index:e,columns:n,values:r}=t,o=st(e),i=o.length,l=new Array(i);for(let x=0;x<i;x++)l[x]=String(o[x]);let a=String(n),u=String(r);for(let x of l)if(!(x in this._columns))throw new B(x,`Pivot index key "${x}" does not exist in the DataFrame.`);if(!(a in this._columns))throw new B(a,`Pivot column key "${a}" does not exist`);if(!(u in this._columns))throw new B(u,`Pivot values key "${u}" does not exist in the DataFrame.`);let c=new Map,f=new Set,h=this._height,p=this._columns[a],m=this._columns[u];for(let x=0;x<h;x++){let I=new Array(i);for(let $=0;$<i;$++){let T=this._columns[l[$]][x];I[$]=T==null?"":String(T)}let U=I.join("\0"),E=String(p[x]);f.add(E);let N=c.get(U);N===void 0&&(N={firstIdx:x,indices:[]},c.set(U,N)),N.indices.push(x)}let y=c.size,d={},b={};for(let x=0;x<i;x++){let I=l[x];d[I]=new Array(y),this._schema[I]&&(b[I]=this._schema[I])}let w=Array.from(f),A=this._schema[u]||L.Utf8;for(let x=0;x<w.length;x++){let I=w[x];d[I]=new Array(y).fill(null),b[I]=A}let S=0;for(let x of c.values()){let I=x.firstIdx;for(let E=0;E<i;E++){let N=l[E];d[N][S]=this._columns[N][I]}let U=x.indices;for(let E=0;E<U.length;E++){let N=U[E],$=String(p[N]);d[$][S]=m[N]}S++}return new s(d,b,y)}rename(t){let e=t||{},n={},r={},o=Object.keys(this._columns);for(let l of o){let a=e[l]||l;n[a]=this._columns[l],r[a]=this._schema[l]}if(Object.keys(n).length<o.length)throw new V("Rename collision: Multiple columns mapped to the same output name.");return new s(n,r,this._height)}reverse(){if(this._height===0)return this;let t={},e=Object.keys(this._columns),n=e.length;for(let r=0;r<n;r++){let o=e[r];t[o]=this._columns[o].slice().reverse()}return new s(t,this._schema,this._height)}get schema(){return this._schema}select(...t){let e=this._normalizeArgs(t),n=Object.keys(this._columns),r=ft(e,n),o={},i={};for(let l of r){let a=l.outputName||l.colName||"*";if(a in o)throw new V(`Duplicate column selection: "${a}" is selected multiple times.`);o[a]=l.isWindow?jt(l,this._columns,this._height):l.evaluate(this._columns,this._height);let u=l.colName||a,c=l instanceof k&&l.ops.length===0&&!l.isWindow&&!l.aggFn;i[a]=c&&this._schema[u]?this._schema[u]:rt(o[a])}return new s(o,i,this._height)}get shape(){return[this.height,this.width]}slice(t,e){let n=this._height,r=t<0?Math.max(n+t,0):Math.min(t,n),o=e===void 0?n:e<0?Math.max(n+e,0):Math.min(e,n),i=Math.max(o-r,0);return this.limit(i,{offset:r})}sort(t){if(!t||!t.by||this._height===0)return this;let{by:e,descending:n=!1,nullsLast:r=!0,custom:o}=t,i=st(e);for(let m=0;m<i.length;m++){let y=i[m];if(typeof y=="string"&&!(y in this._columns))throw new B(y,`Sort key "${y}" does not exist`)}let l=Array.isArray(n)?n:new Array(i.length).fill(n),a=i.length,u=new Array(a);for(let m=0;m<a;m++){let y=i[m],d=l[m]?-1:1,b=o&&typeof y=="string"?o[y]:null,w=y?.evaluate?y.evaluate(this._columns,this._height):this._columns[y]||new Array(this._height).fill(null);u[m]={values:w,isDesc:d,customComp:b}}let c=u.length,f=r?1:-1,h=new Array(this._height);for(let m=0;m<this._height;m++)h[m]=m;h.sort((m,y)=>{for(let d=0;d<c;d++){let{values:b,isDesc:w,customComp:A}=u[d],S=b[m],x=b[y];if(A){let U=A(S,x);if(U!==0)return U*w;continue}if(S==null||x==null){if(S===x)continue;return(S==null?1:-1)*f}if(S===x)continue;return(S<x?-1:1)*w}return 0});let p={};for(let m of Object.keys(this._columns)){let y=this._columns[m],d=new Array(this._height);for(let b=0;b<this._height;b++)d[b]=y[h[b]];p[m]=d}return new s(p,this._schema,this._height)}tail(t=10){return this.limit(t,{offset:0,from:"end"})}to_list(t){if(this._height===0)return[];let e=t&&typeof t!="string"&&"evaluate"in t,n;if(e)n=t.evaluate(this._columns,this._height);else{let r=t;if(r==null)return new Array(this._height).fill(null);let o=this._columns[r];if(!o)throw new B(r,`Column "${r}" does not exist`);n=o}return Array.isArray(n)?n:Array.from(n)}unique(t){if(this._height===0)return new s({},this._schema,0);let e=st(t),n=e.length===0?Object.keys(this._columns):e.map(String);for(let f of n)if(!(f in this._columns))throw new B(f,`Unique column key "${f}" does not exist`);let r=new Set,o=[],i=n.length,l=this._height,a=i===1?this._columns[n[0]]:null;for(let f=0;f<l;f++){let h;if(a){let p=a[f];h=p==null?"":String(p)}else{let p=new Array(i);for(let m=0;m<i;m++){let y=this._columns[n[m]][f];p[m]=y==null?"":String(y)}h=p.join("\0")}r.has(h)||(r.add(h),o.push(f))}let u=o.length,c={};for(let f of Object.keys(this._columns)){let h=this._columns[f],p=new Array(u);for(let m=0;m<u;m++)p[m]=h[o[m]];c[f]=p}return new s(c,this._schema,u)}unpivot(t){let{idVars:e,valueVars:n,varName:r="variable",valueName:o="value"}=t,i=st(e).map(String),l=st(n).map(String),a=i.length,u=l.length;for(let m of i)if(!(m in this._columns))throw new B(m,`Unpivot id variable key "${m}" does not exist`);for(let m of l)if(!(m in this._columns))throw new B(m,`Unpivot value variable key "${m}" does not exist`);let c=this._height*u,f={};for(let m=0;m<a;m++)f[i[m]]=new Array(c);f[r]=new Array(c),f[o]=new Array(c);let h=0;for(let m=0;m<this._height;m++)for(let y=0;y<u;y++){let d=l[y];for(let b=0;b<a;b++){let w=i[b];f[w][h]=this._columns[w][m]}f[r][h]=d,f[o][h]=this._columns[d][m],h++}let p={};for(let m of i)p[m]=this._schema[m];return p[r]=L.Utf8,p[o]=rt(f[o]),new s(f,p,c)}vstack(t){return this.concat(t,{how:"vertical"})}get width(){return Object.keys(this._columns).length}_normalizeArgs(t){let e=t.flat(),n=[];for(let r of e)if(typeof r=="string")n.push(new k(r));else if(Z(r)&&"evaluate"in r)n.push(r);else if(Z(r))for(let[o,i]of Object.entries(r))if(Z(i)&&"evaluate"in i)n.push(i.alias(o));else{let l=new k(o);l.evaluate=(a,u)=>new Array(u).fill(i),n.push(l)}return n}with_columns(...t){let e=this._normalizeArgs(t),n=Object.keys(this._columns),r=ft(e,n),o=r.length,i={...this._columns},l={...this._schema};for(let a=0;a<o;a++){let u=r[a],c=u.outputName||u.colName||"*";u.isWindow?i[c]=jt(u,this._columns,this._height):i[c]=u.evaluate(this._columns,this._height);let f=u.colName||c;u instanceof k&&u.ops.length===0&&!u.isWindow&&!u.aggFn&&this._schema[f]?l[c]=this._schema[f]:l[c]=rt(i[c])}return new s(i,l,this._height)}};var On={data:(s,t)=>new F(s,t),col:s=>new k(s),all:Jt,exclude:Qt,coalesce:te,concat:Dt,lit:it,when:ee,DataType:L};0&&(module.exports={$tbl,ALL_COLUMNS_MARKER,AggregationExpr,ArithmeticExpr,ColumnExpr,ColumnNotFoundError,ComparisonExpr,ComputeError,DataFrame,DataFrameError,DataType,DataTypeRegistry,DateTimeExprNamespace,ExprBase,FrameScriptError,GroupedData,LITERAL_MARKER,ListExpr,ListExprNamespace,LogicalExpr,SchemaError,StringExpr,StringExprNamespace,TemporalExpr,When,WhenThen,WhenThenChain,WindowExpr,all,coalesce,columnsToRows,concat,derive,exclude,getRowFromColumns,inferColumnType,kleeneBinary,kleeneUnary,lit,normalizeToDataFrames,resolveColumnSelectors,resolveWindowExpr,rowsToColumns,when});
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ColumnExpr = void 0;
4
- const ExprBase_1 = require("./ExprBase");
5
- const ArithmeticExpr_1 = require("./mixins/ArithmeticExpr");
6
- const ComparisonExpr_1 = require("./mixins/ComparisonExpr");
7
- const AggregationExpr_1 = require("./mixins/AggregationExpr");
8
- const WindowExpr_1 = require("./mixins/WindowExpr");
9
- const StringExpr_1 = require("./mixins/StringExpr");
10
- const LogicalExpr_1 = require("./mixins/LogicalExpr");
11
- const TemporalExpr_1 = require("./mixins/TemporalExpr");
12
- const ListExpr_1 = require("./mixins/ListExpr");
13
- const ManipulationExpr_1 = require("./mixins/ManipulationExpr");
14
- class ColumnExpr extends (0, ListExpr_1.ListExpr)((0, TemporalExpr_1.TemporalExpr)((0, LogicalExpr_1.LogicalExpr)((0, StringExpr_1.StringExpr)((0, WindowExpr_1.WindowExpr)((0, AggregationExpr_1.AggregationExpr)((0, ComparisonExpr_1.ComparisonExpr)((0, ArithmeticExpr_1.ArithmeticExpr)((0, ManipulationExpr_1.ManipulationExpr)(ExprBase_1.ExprBase))))))))) {
15
- colName;
16
- excludedCols = [];
17
- constructor(colName) {
18
- super();
19
- this.colName = String(colName);
20
- this.outputName = this.colName;
21
- }
22
- }
23
- exports.ColumnExpr = ColumnExpr;