df-script 1.5.0 → 1.7.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 (159) hide show
  1. package/README.md +125 -9
  2. package/dist/api.d.ts +3 -2
  3. package/dist/assets/index-DBhGK6Tp.css +1 -0
  4. package/dist/assets/index-DEJEV_tU.js +195 -0
  5. package/dist/columnExpressions/ColumnExpr.d.ts +14 -7
  6. package/dist/columnExpressions/ExprBase.d.ts +26 -12
  7. package/dist/columnExpressions/constants.d.ts +1 -0
  8. package/dist/columnExpressions/functions/all.d.ts +23 -0
  9. package/dist/columnExpressions/functions/coalesce.d.ts +31 -2
  10. package/dist/columnExpressions/functions/element.d.ts +26 -1
  11. package/dist/columnExpressions/functions/exclude.d.ts +24 -0
  12. package/dist/columnExpressions/functions/implode.d.ts +28 -0
  13. package/dist/columnExpressions/functions/lit.d.ts +27 -0
  14. package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
  15. package/dist/columnExpressions/functions/struct.d.ts +31 -0
  16. package/dist/columnExpressions/functions/when.d.ts +38 -8
  17. package/dist/columnExpressions/index.d.ts +2 -1
  18. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +336 -2
  19. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +620 -10
  20. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +567 -0
  21. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
  22. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
  23. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
  24. package/dist/columnExpressions/mixins/StringExpr.d.ts +658 -5
  25. package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
  26. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +530 -4
  27. package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
  28. package/dist/columnExpressions/types.d.ts +2 -0
  29. package/dist/constants.d.ts +11 -0
  30. package/dist/dataframe/dataframe.d.ts +933 -3
  31. package/dist/dataframe/grouped/grouped.d.ts +41 -6
  32. package/dist/dataframe/types.d.ts +1 -0
  33. package/dist/dataframe/utils.d.ts +1 -0
  34. package/dist/datatypes/index.d.ts +3 -2
  35. package/dist/datatypes/types.d.ts +52 -7
  36. package/dist/exceptions/index.d.ts +23 -0
  37. package/dist/functions/concat.d.ts +50 -0
  38. package/dist/functions/read_csv.d.ts +9 -0
  39. package/dist/functions/read_json.d.ts +7 -2
  40. package/dist/index.html +17 -0
  41. package/dist/index.js +6 -6
  42. package/dist/index.mjs +6 -0
  43. package/dist/types.d.ts +51 -16
  44. package/dist/utils/{list.d.ts → array.d.ts} +68 -15
  45. package/dist/utils/binary.d.ts +3 -0
  46. package/dist/utils/csv.d.ts +1 -0
  47. package/dist/utils/date.d.ts +23 -54
  48. package/dist/utils/index.d.ts +3 -2
  49. package/dist/utils/json.d.ts +1 -0
  50. package/dist/utils/number.d.ts +15 -29
  51. package/dist/utils/object.d.ts +27 -0
  52. package/dist/utils/string.d.ts +15 -5
  53. package/package.json +18 -4
  54. package/dist/api.js +0 -26
  55. package/dist/bundle.min.js +0 -1
  56. package/dist/columnExpressions/ColumnExpr.js +0 -219
  57. package/dist/columnExpressions/ExprBase.js +0 -92
  58. package/dist/columnExpressions/constants.js +0 -7
  59. package/dist/columnExpressions/functions/all.js +0 -11
  60. package/dist/columnExpressions/functions/coalesce.js +0 -44
  61. package/dist/columnExpressions/functions/element.js +0 -11
  62. package/dist/columnExpressions/functions/exclude.js +0 -13
  63. package/dist/columnExpressions/functions/implode.js +0 -7
  64. package/dist/columnExpressions/functions/lit.js +0 -17
  65. package/dist/columnExpressions/functions/repeat.d.ts +0 -47
  66. package/dist/columnExpressions/functions/repeat.js +0 -131
  67. package/dist/columnExpressions/functions/seq_range.js +0 -91
  68. package/dist/columnExpressions/functions/when.js +0 -85
  69. package/dist/columnExpressions/index.js +0 -38
  70. package/dist/columnExpressions/mixins/AggregationExpr.js +0 -76
  71. package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -131
  72. package/dist/columnExpressions/mixins/BooleanExpr.d.ts +0 -40
  73. package/dist/columnExpressions/mixins/BooleanExpr.js +0 -67
  74. package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -250
  75. package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
  76. package/dist/columnExpressions/mixins/ListExpr.js +0 -224
  77. package/dist/columnExpressions/mixins/LogicalExpr.js +0 -53
  78. package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -71
  79. package/dist/columnExpressions/mixins/NumericExpr.d.ts +0 -92
  80. package/dist/columnExpressions/mixins/NumericExpr.js +0 -259
  81. package/dist/columnExpressions/mixins/StringExpr.js +0 -237
  82. package/dist/columnExpressions/mixins/StructExpr.js +0 -139
  83. package/dist/columnExpressions/mixins/TemporalExpr.js +0 -126
  84. package/dist/columnExpressions/mixins/WindowExpr.js +0 -151
  85. package/dist/columnExpressions/types.js +0 -2
  86. package/dist/columnExpressions/utils.js +0 -45
  87. package/dist/dataframe/constants.js +0 -7
  88. package/dist/dataframe/dataframe.js +0 -990
  89. package/dist/dataframe/grouped/grouped.js +0 -114
  90. package/dist/dataframe/index.js +0 -20
  91. package/dist/dataframe/types.js +0 -2
  92. package/dist/dataframe/utils.js +0 -307
  93. package/dist/datatypes/DataType.js +0 -76
  94. package/dist/datatypes/index.js +0 -46
  95. package/dist/datatypes/types/Binary.d.ts +0 -9
  96. package/dist/datatypes/types/Binary.js +0 -18
  97. package/dist/datatypes/types/Boolean.d.ts +0 -9
  98. package/dist/datatypes/types/Boolean.js +0 -19
  99. package/dist/datatypes/types/Date.d.ts +0 -8
  100. package/dist/datatypes/types/Date.js +0 -21
  101. package/dist/datatypes/types/Datetime.d.ts +0 -8
  102. package/dist/datatypes/types/Datetime.js +0 -17
  103. package/dist/datatypes/types/Decimal.d.ts +0 -10
  104. package/dist/datatypes/types/Decimal.js +0 -28
  105. package/dist/datatypes/types/Duration.d.ts +0 -8
  106. package/dist/datatypes/types/Duration.js +0 -17
  107. package/dist/datatypes/types/Float32.d.ts +0 -8
  108. package/dist/datatypes/types/Float32.js +0 -17
  109. package/dist/datatypes/types/Float64.d.ts +0 -8
  110. package/dist/datatypes/types/Float64.js +0 -17
  111. package/dist/datatypes/types/Int16.d.ts +0 -8
  112. package/dist/datatypes/types/Int16.js +0 -17
  113. package/dist/datatypes/types/Int32.d.ts +0 -8
  114. package/dist/datatypes/types/Int32.js +0 -17
  115. package/dist/datatypes/types/Int64.d.ts +0 -8
  116. package/dist/datatypes/types/Int64.js +0 -17
  117. package/dist/datatypes/types/Int8.d.ts +0 -8
  118. package/dist/datatypes/types/Int8.js +0 -17
  119. package/dist/datatypes/types/List.d.ts +0 -10
  120. package/dist/datatypes/types/List.js +0 -31
  121. package/dist/datatypes/types/Null.d.ts +0 -9
  122. package/dist/datatypes/types/Null.js +0 -17
  123. package/dist/datatypes/types/Object.d.ts +0 -9
  124. package/dist/datatypes/types/Object.js +0 -17
  125. package/dist/datatypes/types/Struct.d.ts +0 -14
  126. package/dist/datatypes/types/Struct.js +0 -39
  127. package/dist/datatypes/types/Time.d.ts +0 -8
  128. package/dist/datatypes/types/Time.js +0 -29
  129. package/dist/datatypes/types/UInt16.d.ts +0 -8
  130. package/dist/datatypes/types/UInt16.js +0 -17
  131. package/dist/datatypes/types/UInt32.d.ts +0 -8
  132. package/dist/datatypes/types/UInt32.js +0 -17
  133. package/dist/datatypes/types/UInt64.d.ts +0 -8
  134. package/dist/datatypes/types/UInt64.js +0 -17
  135. package/dist/datatypes/types/UInt8.d.ts +0 -8
  136. package/dist/datatypes/types/UInt8.js +0 -17
  137. package/dist/datatypes/types/Utf8.d.ts +0 -10
  138. package/dist/datatypes/types/Utf8.js +0 -20
  139. package/dist/datatypes/types.js +0 -290
  140. package/dist/exceptions/index.js +0 -46
  141. package/dist/exceptions/utils.js +0 -28
  142. package/dist/functions/concat.js +0 -260
  143. package/dist/functions/index.js +0 -9
  144. package/dist/functions/read_csv.js +0 -53
  145. package/dist/functions/read_json.js +0 -21
  146. package/dist/functions/transpose.d.ts +0 -7
  147. package/dist/functions/transpose.js +0 -84
  148. package/dist/types.js +0 -2
  149. package/dist/utils/boolean.d.ts +0 -1
  150. package/dist/utils/boolean.js +0 -18
  151. package/dist/utils/csv.js +0 -313
  152. package/dist/utils/date.js +0 -348
  153. package/dist/utils/guards.d.ts +0 -12
  154. package/dist/utils/guards.js +0 -112
  155. package/dist/utils/index.js +0 -23
  156. package/dist/utils/json.js +0 -217
  157. package/dist/utils/list.js +0 -361
  158. package/dist/utils/number.js +0 -401
  159. package/dist/utils/string.js +0 -209
@@ -6,24 +6,31 @@ import { WindowExpr } from "./mixins/WindowExpr";
6
6
  import { StringExpr } from "./mixins/StringExpr";
7
7
  import { LogicalExpr } from "./mixins/LogicalExpr";
8
8
  import { TemporalExpr } from "./mixins/TemporalExpr";
9
- import { ListExpr } from "./mixins/ListExpr";
9
+ import { ArrayExpr } from "./mixins/ArrayExpr";
10
10
  import { StructExpr } from "./mixins/StructExpr";
11
11
  import { ManipulationExpr } from "./mixins/ManipulationExpr";
12
12
  import { DataType } from "../datatypes";
13
13
  import type { IntoExpr, IExpr, DataFrameSchema, ColumnDict } from "../types";
14
14
  export declare class ColumnExpr<T> extends ExprBase {
15
- colName: string;
16
- colNames?: string[];
17
- excludedCols: string[];
18
- targetType?: any;
19
- targetTypes?: any[];
15
+ _colName: string;
16
+ _colNames?: string[];
17
+ _excludedCols: string[];
18
+ _targetType?: any;
19
+ _targetTypes?: any[];
20
20
  static isColExpr(v: unknown): v is ColumnExpr<any>;
21
21
  static toColExpr(col: IntoExpr | IntoExpr[]): ColumnExpr<any>;
22
+ /**
23
+ * Creates a column expression representing a column or a raw expression value.
24
+ * @namespace $df.col
25
+ * @category ColumnExpression
26
+ * @syntax $df.col(<column_name>).{symbol}(...)
27
+ */
22
28
  constructor(colName: keyof T | string | (keyof T | string)[] | DataType | Function | (DataType | Function)[]);
23
29
  }
24
- export interface ColumnExpr<T> extends ArithmeticExpr, ComparisonExpr, AggregationExpr, WindowExpr, StringExpr, LogicalExpr, TemporalExpr, ListExpr, StructExpr, ManipulationExpr {
30
+ export interface ColumnExpr<T> extends ArithmeticExpr, ComparisonExpr, AggregationExpr, WindowExpr, StringExpr, LogicalExpr, TemporalExpr, ArrayExpr, StructExpr, ManipulationExpr {
25
31
  }
26
32
  /**
33
+ * @internal
27
34
  * Resolves column selectors, expanding wildcards, datatypes, and arrays of columns/types
28
35
  * into concrete ColumnExpr instances.
29
36
  */
@@ -1,21 +1,35 @@
1
1
  import type { IExpr, OpFn, AggFn, ColumnData, ColumnDict, RegisteredDataType } from "../types";
2
2
  export declare const derive: <T extends IExpr>(instance: T, nextOp?: OpFn) => T;
3
+ /**
4
+ * @namespace $df.col
5
+ * @category ColumnExpression
6
+ * @syntax $df.col(<column_name>).{symbol}(...)
7
+ */
3
8
  export declare class ExprBase implements IExpr {
4
- ops: OpFn[];
5
- outputName: string;
6
- isLiteral?: boolean;
7
- literalValue?: any;
8
- aggFn?: AggFn<any> | null;
9
- groupingOpsIndex?: number;
10
- partitionOpsIndex?: number;
11
- partitionBy: (string | IExpr)[] | null;
12
- evaluateWindow?: (groupPreValues: any[], partitionIndices: number[], currentIndex: number) => any;
9
+ _ops: OpFn[];
10
+ _outputName: string;
11
+ _isLiteral?: boolean;
12
+ _literalValue?: any;
13
+ _aggFn?: AggFn<any> | null;
14
+ _groupingOpsIndex?: number;
15
+ _partitionOpsIndex?: number;
16
+ _partitionBy: (string | IExpr)[] | null;
17
+ _evaluateWindow?: (groupPreValues: any[], partitionIndices: number[], currentIndex: number) => any;
18
+ _evaluatePost(opsIndex: number | undefined, aggregatedArray: any[], columns: ColumnDict): ColumnData;
19
+ _evaluatePre(opsIndex: number | undefined, columns: ColumnDict, height: number): ColumnData;
20
+ _getInitialValue(columns: ColumnDict, height: number): ColumnData;
13
21
  _resolve(val: any, columns: ColumnDict, height: number): any;
22
+ /**
23
+ * Renames the output expression column key.
24
+ */
14
25
  alias(name: string): this;
26
+ /**
27
+ * Coerces the column data type to another type.
28
+ */
15
29
  cast(dataType: RegisteredDataType): this;
30
+ /**
31
+ * Prints the current evaluation intermediate array to console for debugging.
32
+ */
16
33
  debug(label?: string): this;
17
- private _getInitialValue;
18
34
  evaluate(columns: ColumnDict, height: number): ColumnData;
19
- evaluatePre(opsIndex: number | undefined, columns: ColumnDict, height: number): ColumnData;
20
- evaluatePost(opsIndex: number | undefined, aggregatedArray: any[], columns: ColumnDict): ColumnData;
21
35
  }
@@ -2,3 +2,4 @@ export declare const ALL_COLUMNS_MARKER = "*";
2
2
  export declare const LITERAL_MARKER = "*literal*";
3
3
  export declare const COALESCE_MARKER = "*coalesce*";
4
4
  export declare const ELEMENT_MARKER = "*element*";
5
+ export declare const STRUCT_MARKER = "*struct*";
@@ -1,5 +1,28 @@
1
1
  import { ColumnExpr } from "../ColumnExpr";
2
2
  /**
3
3
  * Creates an expression targeting all columns in the DataFrame.
4
+ *
5
+ * @returns {ColumnExpr<any>} A column expression targeting all columns.
6
+ * @namespace $df
7
+ * @category ColumnExpression
8
+ * @syntax $df.{symbol}(...)
9
+ * @example
10
+ * >>> const df = $df.data({ a: [1, 2], b: [3, 4] })
11
+ * >>> df
12
+ * shape: (2, 2)
13
+ * ┌─────┬─────┐
14
+ * │ a │ b │
15
+ * ├─────┼─────┤
16
+ * │ 1 │ 3 │
17
+ * │ 2 │ 4 │
18
+ * └─────┴─────┘
19
+ * >>> df.select($df.all())
20
+ * shape: (2, 2)
21
+ * ┌─────┬─────┐
22
+ * │ a │ b │
23
+ * ├─────┼─────┤
24
+ * │ 1 │ 3 │
25
+ * │ 2 │ 4 │
26
+ * └─────┴─────┘
4
27
  */
5
28
  export declare function all(): ColumnExpr<any>;
@@ -1,3 +1,32 @@
1
1
  import { ColumnExpr } from "../ColumnExpr";
2
- import type { IExpr, Scalar } from "../../types";
3
- export declare function coalesce(...exprs: (IExpr | Scalar | (IExpr | Scalar)[])[]): ColumnExpr<any>;
2
+ import type { IExpr, ValidScalarTypes } from "../../types";
3
+ /**
4
+ * Returns the first non-null value among the specified expressions.
5
+ *
6
+ * @param {...(IExpr | ValidScalarTypes | (IExpr | ValidScalarTypes)[])[]} exprs The list of expressions or columns to coalesce.
7
+ * @returns {ColumnExpr<any>} A column expression resolving to the first non-null value.
8
+ * @namespace $df
9
+ * @category ColumnExpression
10
+ * @syntax $df.{symbol}(...)
11
+ * @example
12
+ * >>> const df = $df.data({ a: [1, null, null], b: [null, 2, null] })
13
+ * >>> df
14
+ * shape: (3, 2)
15
+ * ┌──────┬──────┐
16
+ * │ a │ b │
17
+ * ├──────┼──────┤
18
+ * │ 1 │ null │
19
+ * │ null │ 2 │
20
+ * │ null │ null │
21
+ * └──────┴──────┘
22
+ * >>> df.select($df.coalesce($df.col("a"), $df.col("b"), $df.lit(3)).alias("coalesced"))
23
+ * shape: (3, 1)
24
+ * ┌───────────┐
25
+ * │ coalesced │
26
+ * ├───────────┤
27
+ * │ 1 │
28
+ * │ 2 │
29
+ * │ 3 │
30
+ * └───────────┘
31
+ */
32
+ export declare function coalesce(...exprs: (IExpr | ValidScalarTypes | (IExpr | ValidScalarTypes)[])[]): ColumnExpr<any>;
@@ -1,5 +1,30 @@
1
1
  import { ColumnExpr } from "../ColumnExpr";
2
2
  /**
3
- * Creates an expression referencing the current element(s) of a list during evaluation.
3
+ * Creates an expression referencing the current element(s) of an array during evaluation.
4
+ * Primarily used inside array operations like `filter`, `map`, or `eval`.
5
+ *
6
+ * @template T The type of the element.
7
+ * @returns {ColumnExpr<T>} A column expression referencing the array element.
8
+ * @namespace $df
9
+ * @category ColumnExpression
10
+ * @syntax $df.{symbol}(...)
11
+ * @example
12
+ * >>> const df = $df.data({ a: [[1, 5, 10], [2, 8]] })
13
+ * >>> df
14
+ * shape: (2, 1)
15
+ * ┌────────────┐
16
+ * │ a │
17
+ * ├────────────┤
18
+ * │ [1, 5, 10] │
19
+ * │ [2, 8] │
20
+ * └────────────┘
21
+ * >>> df.select($df.col("a").arr.filter($df.element().gt(5)).alias("filtered"))
22
+ * shape: (2, 1)
23
+ * ┌──────────┐
24
+ * │ filtered │
25
+ * ├──────────┤
26
+ * │ [10] │
27
+ * │ [8] │
28
+ * └──────────┘
4
29
  */
5
30
  export declare function element<T = any>(): ColumnExpr<T>;
@@ -1,5 +1,29 @@
1
1
  import { ColumnExpr } from "../ColumnExpr";
2
2
  /**
3
3
  * Creates an expression targeting all columns except the specified ones.
4
+ *
5
+ * @param {string | string[]} columns The name or names of columns to exclude.
6
+ * @returns {ColumnExpr<any>} A column expression targeting all columns except the specified ones.
7
+ * @namespace $df
8
+ * @category ColumnExpression
9
+ * @syntax $df.{symbol}(...)
10
+ * @example
11
+ * >>> const df = $df.data({ id: [101, 102], val: [10, 20] })
12
+ * >>> df
13
+ * shape: (2, 2)
14
+ * ┌─────┬─────┐
15
+ * │ id │ val │
16
+ * ├─────┼─────┤
17
+ * │ 101 │ 10 │
18
+ * │ 102 │ 20 │
19
+ * └─────┴─────┘
20
+ * >>> df.select($df.exclude("id"))
21
+ * shape: (2, 1)
22
+ * ┌─────┐
23
+ * │ val │
24
+ * ├─────┤
25
+ * │ 10 │
26
+ * │ 20 │
27
+ * └─────┘
4
28
  */
5
29
  export declare function exclude(columns: string | string[]): ColumnExpr<any>;
@@ -1,3 +1,31 @@
1
1
  import { ColumnExpr } from "../ColumnExpr";
2
2
  import type { IntoExpr } from "../../types";
3
+ /**
4
+ * Aggregates values of a column into a list within each group.
5
+ *
6
+ * @param {IntoExpr | IntoExpr[]} column The column or expression to implode.
7
+ * @returns {ColumnExpr<any>} A column expression representing the list of values.
8
+ * @namespace $df
9
+ * @category ColumnExpression
10
+ * @syntax $df.{symbol}(...)
11
+ * @example
12
+ * >>> const df = $df.data({ group: ["A", "A", "B"], val: [1, 2, 3] })
13
+ * >>> df
14
+ * shape: (3, 2)
15
+ * ┌───────┬─────┐
16
+ * │ group │ val │
17
+ * ├───────┼─────┤
18
+ * │ A │ 1 │
19
+ * │ A │ 2 │
20
+ * │ B │ 3 │
21
+ * └───────┴─────┘
22
+ * >>> df.group_by("group").agg($df.implode("val").alias("imploded"))
23
+ * shape: (2, 2)
24
+ * ┌───────┬──────────┐
25
+ * │ group │ imploded │
26
+ * ├───────┼──────────┤
27
+ * │ A │ [1, 2] │
28
+ * │ B │ [3] │
29
+ * └───────┴──────────┘
30
+ */
3
31
  export declare function implode(column: IntoExpr | IntoExpr[]): ColumnExpr<any>;
@@ -3,5 +3,32 @@ import type { SeqRangeOptions } from "./seq_range";
3
3
  export type LitOptions = Pick<SeqRangeOptions, "dtype" | "name">;
4
4
  /**
5
5
  * Creates a literal column expression that repeats the given value for all rows.
6
+ *
7
+ * @param value The literal value (number, string, boolean, etc.).
8
+ * @param [options] Configuration options.
9
+ * @param [options.dtype] The data type to allocate for the literal values.
10
+ * @param [options.name] The name of the output column.
11
+ * @returns {ColumnExpr<any>} A column expression with the literal value.
12
+ * @namespace $df
13
+ * @category ColumnExpression
14
+ * @syntax $df.{symbol}(...)
15
+ * @example
16
+ * >>> const df = $df.data({ a: [1, 2] })
17
+ * >>> df
18
+ * shape: (2, 1)
19
+ * ┌───┐
20
+ * │ a │
21
+ * ├───┤
22
+ * │ 1 │
23
+ * │ 2 │
24
+ * └───┘
25
+ * >>> df.select($df.lit(42).alias("answer"))
26
+ * shape: (2, 1)
27
+ * ┌────────┐
28
+ * │ answer │
29
+ * ├────────┤
30
+ * │ 42 │
31
+ * │ 42 │
32
+ * └────────┘
6
33
  */
7
34
  export declare function lit(value: any, options?: LitOptions): ColumnExpr<any>;
@@ -27,5 +27,41 @@ export type SeqRangeOptions = {
27
27
  * Creates a column expression that generates a range of values.
28
28
  * If mode is "cumulative" (default) or "independent", it generates a sequence.
29
29
  * If mode is "constant", it repeats the given value.
30
+ *
31
+ * @param value The initial value to start the sequence or the constant value to repeat.
32
+ * @param [options] Configuration options.
33
+ * @param [options.n] The number of values to generate. Defaults to the slice/DataFrame height.
34
+ * @param [options.dtype] The registered data type to coerce/allocate for the generated sequence.
35
+ * @param [options.name] The name of the output column.
36
+ * @param [options.mode] The sequence generation mode ("constant", "cumulative", or "independent").
37
+ * @param [options.step] The step value or function to compute the step at each row.
38
+ * @param [options.strict] If true, throws an error if the generated sequence height does not match the target height.
39
+ * @param [options.pad] In non-strict mode, pads the sequence with `padValue` if it is shorter than target range.
40
+ * @param [options.truncate] In non-strict mode, truncates the sequence if it exceeds target range.
41
+ * @param [options.padValue] The value to use for padding in non-strict mode.
42
+ * @param [options.startIndex] The starting index in the DataFrame to insert the sequence.
43
+ * @param [options.endIndex] The ending index in the DataFrame to insert the sequence.
44
+ * @returns {ColumnExpr<any>} A column expression generating the sequence.
45
+ * @namespace $df
46
+ * @category ColumnExpression
47
+ * @syntax $df.{symbol}(...)
48
+ * @example
49
+ * >>> const df = $df.data({ a: [10, 20] })
50
+ * >>> df
51
+ * shape: (2, 1)
52
+ * ┌────┐
53
+ * │ a │
54
+ * ├────┤
55
+ * │ 10 │
56
+ * │ 20 │
57
+ * └────┘
58
+ * >>> df.select($df.seq_range(1, { step: 2 }).alias("odd"))
59
+ * shape: (2, 1)
60
+ * ┌─────┐
61
+ * │ odd │
62
+ * ├─────┤
63
+ * │ 1 │
64
+ * │ 3 │
65
+ * └─────┘
30
66
  */
31
67
  export declare function seq_range(value: any, options?: SeqRangeOptions): ColumnExpr<any>;
@@ -0,0 +1,31 @@
1
+ import { ColumnExpr } from "../ColumnExpr";
2
+ import type { IntoExpr } from "../../types";
3
+ /**
4
+ * Packages multiple expressions into a structured object column.
5
+ *
6
+ * @param {IntoExpr[] | Record<string, IntoExpr> | IntoExpr} fields An array of expressions, a record of field names to expressions, or a single expression.
7
+ * @param {...IntoExpr[]} moreFields Additional fields when a single expression is passed as the first parameter.
8
+ * @returns {ColumnExpr<any>} A column expression packaging the specified fields.
9
+ * @namespace $df
10
+ * @category ColumnExpression
11
+ * @syntax $df.{symbol}(...)
12
+ * @example
13
+ * >>> const df = $df.data({ a: [1, 2], b: ["x", "y"] })
14
+ * >>> df
15
+ * shape: (2, 2)
16
+ * ┌─────┬─────┐
17
+ * │ a │ b │
18
+ * ├─────┼─────┤
19
+ * │ 1 │ x │
20
+ * │ 2 │ y │
21
+ * └─────┴─────┘
22
+ * >>> df.select($df.struct({ x: "a", y: "b" }).alias("coord"))
23
+ * shape: (2, 1)
24
+ * ┌──────────────────┐
25
+ * │ coord │
26
+ * ├──────────────────┤
27
+ * │ { x: 1, y: "x" } │
28
+ * │ { x: 2, y: "y" } │
29
+ * └──────────────────┘
30
+ */
31
+ export declare function struct(fields: IntoExpr[] | Record<string, IntoExpr> | IntoExpr, ...moreFields: IntoExpr[]): ColumnExpr<any>;
@@ -1,24 +1,54 @@
1
1
  import { ColumnExpr } from "../ColumnExpr";
2
- import type { IExpr, Scalar } from "../../types";
3
- type WhenArg = IExpr | Scalar;
2
+ import type { IExpr, ValidScalarTypes } from "../../types";
3
+ type WhenArg = IExpr | ValidScalarTypes;
4
4
  export declare class WhenThenChain {
5
- private predicates;
6
- private values;
5
+ private _predicates;
6
+ private _values;
7
7
  constructor(predicates: WhenArg[], values: WhenArg[]);
8
8
  then(value: WhenArg): WhenThen;
9
9
  }
10
10
  export declare class When {
11
- private predicates;
11
+ private _predicates;
12
12
  constructor(predicate: WhenArg);
13
13
  then(value: WhenArg): WhenThen;
14
14
  }
15
15
  export declare class WhenThen extends ColumnExpr<any> {
16
- private predicates;
17
- private values;
18
- private otherwiseValue;
16
+ private _predicates;
17
+ private _values;
18
+ private _otherwiseValue;
19
19
  constructor(predicates: WhenArg[] | string, values?: WhenArg[], otherwiseValue?: WhenArg);
20
20
  when(predicate: WhenArg): WhenThenChain;
21
21
  otherwise(value: WhenArg): ColumnExpr<any>;
22
22
  }
23
+ /**
24
+ * Provides conditional branch evaluations inside column expressions.
25
+ *
26
+ * @param {WhenArg} predicate The boolean condition or expression.
27
+ * @returns {When} A When object builder to chain `.then()` and `.otherwise()`/`.when()`.
28
+ * @namespace $df
29
+ * @category ColumnExpression
30
+ * @syntax $df.{symbol}(...)
31
+ * @example
32
+ * >>> const df = $df.data({ score: [75, 95] })
33
+ * >>> df
34
+ * shape: (2, 1)
35
+ * ┌───────┐
36
+ * │ score │
37
+ * ├───────┤
38
+ * │ 75 │
39
+ * │ 95 │
40
+ * └───────┘
41
+ * >>> df.select(
42
+ * ... $df.when($df.col("score").gt(90)).then("A")
43
+ * ... .otherwise("B").alias("grade")
44
+ * ... )
45
+ * shape: (2, 1)
46
+ * ┌───────┐
47
+ * │ grade │
48
+ * ├───────┤
49
+ * │ B │
50
+ * │ A │
51
+ * └───────┘
52
+ */
23
53
  export declare function when(predicate: WhenArg): When;
24
54
  export {};
@@ -8,7 +8,7 @@ export * from "./mixins/StringExpr";
8
8
  export * from "./mixins/AggregationExpr";
9
9
  export * from "./mixins/WindowExpr";
10
10
  export * from "./mixins/TemporalExpr";
11
- export * from "./mixins/ListExpr";
11
+ export * from "./mixins/ArrayExpr";
12
12
  export * from "./mixins/StructExpr";
13
13
  export * from "./ColumnExpr";
14
14
  export * from "./functions/lit";
@@ -19,4 +19,5 @@ export * from "./functions/when";
19
19
  export * from "./functions/implode";
20
20
  export * from "./functions/seq_range";
21
21
  export * from "./functions/element";
22
+ export * from "./functions/struct";
22
23
  export * from "./utils";