df-script 1.6.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.
- package/README.md +1 -1
- package/dist/api.d.ts +2 -1
- package/dist/assets/index-DBhGK6Tp.css +1 -0
- package/dist/assets/index-DEJEV_tU.js +195 -0
- package/dist/columnExpressions/ColumnExpr.d.ts +12 -5
- package/dist/columnExpressions/ExprBase.d.ts +26 -12
- package/dist/columnExpressions/constants.d.ts +1 -0
- package/dist/columnExpressions/functions/all.d.ts +23 -0
- package/dist/columnExpressions/functions/coalesce.d.ts +29 -0
- package/dist/columnExpressions/functions/element.d.ts +25 -0
- package/dist/columnExpressions/functions/exclude.d.ts +24 -0
- package/dist/columnExpressions/functions/implode.d.ts +28 -0
- package/dist/columnExpressions/functions/lit.d.ts +27 -0
- package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
- package/dist/columnExpressions/functions/struct.d.ts +31 -0
- package/dist/columnExpressions/functions/when.d.ts +36 -6
- package/dist/columnExpressions/index.d.ts +1 -0
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +334 -0
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +609 -0
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +533 -5
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +656 -3
- package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +530 -4
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
- package/dist/columnExpressions/types.d.ts +1 -0
- package/dist/dataframe/dataframe.d.ts +932 -2
- package/dist/dataframe/grouped/grouped.d.ts +41 -6
- package/dist/dataframe/types.d.ts +1 -0
- package/dist/dataframe/utils.d.ts +1 -0
- package/dist/datatypes/types.d.ts +45 -0
- package/dist/exceptions/index.d.ts +23 -0
- package/dist/functions/concat.d.ts +50 -0
- package/dist/functions/read_csv.d.ts +9 -0
- package/dist/functions/read_json.d.ts +7 -2
- package/dist/index.html +17 -0
- package/dist/index.js +5 -5
- package/dist/index.mjs +6 -0
- package/dist/types.d.ts +47 -14
- package/dist/utils/array.d.ts +32 -1
- package/dist/utils/csv.d.ts +1 -0
- package/dist/utils/date.d.ts +10 -27
- package/dist/utils/json.d.ts +1 -0
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/string.d.ts +12 -0
- package/package.json +18 -4
- package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
- package/dist/utils/guards.d.ts +0 -13
- package/dist/utils/list.d.ts +0 -217
|
@@ -12,18 +12,25 @@ 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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
}
|
|
@@ -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
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
|
+
*/
|
|
3
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
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>;
|
|
@@ -2,23 +2,53 @@ import { ColumnExpr } from "../ColumnExpr";
|
|
|
2
2
|
import type { IExpr, ValidScalarTypes } from "../../types";
|
|
3
3
|
type WhenArg = IExpr | ValidScalarTypes;
|
|
4
4
|
export declare class WhenThenChain {
|
|
5
|
-
private
|
|
6
|
-
private
|
|
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
|
|
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
|
|
17
|
-
private
|
|
18
|
-
private
|
|
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 {};
|