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.
- package/README.md +125 -9
- package/dist/api.d.ts +3 -2
- package/dist/assets/index-DBhGK6Tp.css +1 -0
- package/dist/assets/index-DEJEV_tU.js +195 -0
- package/dist/columnExpressions/ColumnExpr.d.ts +14 -7
- 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 +31 -2
- package/dist/columnExpressions/functions/element.d.ts +26 -1
- 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 +38 -8
- package/dist/columnExpressions/index.d.ts +2 -1
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +336 -2
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +620 -10
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +567 -0
- 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 +658 -5
- 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 +2 -0
- package/dist/constants.d.ts +11 -0
- package/dist/dataframe/dataframe.d.ts +933 -3
- 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/index.d.ts +3 -2
- package/dist/datatypes/types.d.ts +52 -7
- 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 +6 -6
- package/dist/index.mjs +6 -0
- package/dist/types.d.ts +51 -16
- package/dist/utils/{list.d.ts → array.d.ts} +68 -15
- package/dist/utils/binary.d.ts +3 -0
- package/dist/utils/csv.d.ts +1 -0
- package/dist/utils/date.d.ts +23 -54
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/json.d.ts +1 -0
- package/dist/utils/number.d.ts +15 -29
- package/dist/utils/object.d.ts +27 -0
- package/dist/utils/string.d.ts +15 -5
- package/package.json +18 -4
- package/dist/api.js +0 -26
- package/dist/bundle.min.js +0 -1
- package/dist/columnExpressions/ColumnExpr.js +0 -219
- package/dist/columnExpressions/ExprBase.js +0 -92
- package/dist/columnExpressions/constants.js +0 -7
- package/dist/columnExpressions/functions/all.js +0 -11
- package/dist/columnExpressions/functions/coalesce.js +0 -44
- package/dist/columnExpressions/functions/element.js +0 -11
- package/dist/columnExpressions/functions/exclude.js +0 -13
- package/dist/columnExpressions/functions/implode.js +0 -7
- package/dist/columnExpressions/functions/lit.js +0 -17
- package/dist/columnExpressions/functions/repeat.d.ts +0 -47
- package/dist/columnExpressions/functions/repeat.js +0 -131
- package/dist/columnExpressions/functions/seq_range.js +0 -91
- package/dist/columnExpressions/functions/when.js +0 -85
- package/dist/columnExpressions/index.js +0 -38
- package/dist/columnExpressions/mixins/AggregationExpr.js +0 -76
- package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -131
- package/dist/columnExpressions/mixins/BooleanExpr.d.ts +0 -40
- package/dist/columnExpressions/mixins/BooleanExpr.js +0 -67
- package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -250
- package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
- package/dist/columnExpressions/mixins/ListExpr.js +0 -224
- package/dist/columnExpressions/mixins/LogicalExpr.js +0 -53
- package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -71
- package/dist/columnExpressions/mixins/NumericExpr.d.ts +0 -92
- package/dist/columnExpressions/mixins/NumericExpr.js +0 -259
- package/dist/columnExpressions/mixins/StringExpr.js +0 -237
- package/dist/columnExpressions/mixins/StructExpr.js +0 -139
- package/dist/columnExpressions/mixins/TemporalExpr.js +0 -126
- package/dist/columnExpressions/mixins/WindowExpr.js +0 -151
- package/dist/columnExpressions/types.js +0 -2
- package/dist/columnExpressions/utils.js +0 -45
- package/dist/dataframe/constants.js +0 -7
- package/dist/dataframe/dataframe.js +0 -990
- package/dist/dataframe/grouped/grouped.js +0 -114
- package/dist/dataframe/index.js +0 -20
- package/dist/dataframe/types.js +0 -2
- package/dist/dataframe/utils.js +0 -307
- package/dist/datatypes/DataType.js +0 -76
- package/dist/datatypes/index.js +0 -46
- package/dist/datatypes/types/Binary.d.ts +0 -9
- package/dist/datatypes/types/Binary.js +0 -18
- package/dist/datatypes/types/Boolean.d.ts +0 -9
- package/dist/datatypes/types/Boolean.js +0 -19
- package/dist/datatypes/types/Date.d.ts +0 -8
- package/dist/datatypes/types/Date.js +0 -21
- package/dist/datatypes/types/Datetime.d.ts +0 -8
- package/dist/datatypes/types/Datetime.js +0 -17
- package/dist/datatypes/types/Decimal.d.ts +0 -10
- package/dist/datatypes/types/Decimal.js +0 -28
- package/dist/datatypes/types/Duration.d.ts +0 -8
- package/dist/datatypes/types/Duration.js +0 -17
- package/dist/datatypes/types/Float32.d.ts +0 -8
- package/dist/datatypes/types/Float32.js +0 -17
- package/dist/datatypes/types/Float64.d.ts +0 -8
- package/dist/datatypes/types/Float64.js +0 -17
- package/dist/datatypes/types/Int16.d.ts +0 -8
- package/dist/datatypes/types/Int16.js +0 -17
- package/dist/datatypes/types/Int32.d.ts +0 -8
- package/dist/datatypes/types/Int32.js +0 -17
- package/dist/datatypes/types/Int64.d.ts +0 -8
- package/dist/datatypes/types/Int64.js +0 -17
- package/dist/datatypes/types/Int8.d.ts +0 -8
- package/dist/datatypes/types/Int8.js +0 -17
- package/dist/datatypes/types/List.d.ts +0 -10
- package/dist/datatypes/types/List.js +0 -31
- package/dist/datatypes/types/Null.d.ts +0 -9
- package/dist/datatypes/types/Null.js +0 -17
- package/dist/datatypes/types/Object.d.ts +0 -9
- package/dist/datatypes/types/Object.js +0 -17
- package/dist/datatypes/types/Struct.d.ts +0 -14
- package/dist/datatypes/types/Struct.js +0 -39
- package/dist/datatypes/types/Time.d.ts +0 -8
- package/dist/datatypes/types/Time.js +0 -29
- package/dist/datatypes/types/UInt16.d.ts +0 -8
- package/dist/datatypes/types/UInt16.js +0 -17
- package/dist/datatypes/types/UInt32.d.ts +0 -8
- package/dist/datatypes/types/UInt32.js +0 -17
- package/dist/datatypes/types/UInt64.d.ts +0 -8
- package/dist/datatypes/types/UInt64.js +0 -17
- package/dist/datatypes/types/UInt8.d.ts +0 -8
- package/dist/datatypes/types/UInt8.js +0 -17
- package/dist/datatypes/types/Utf8.d.ts +0 -10
- package/dist/datatypes/types/Utf8.js +0 -20
- package/dist/datatypes/types.js +0 -290
- package/dist/exceptions/index.js +0 -46
- package/dist/exceptions/utils.js +0 -28
- package/dist/functions/concat.js +0 -260
- package/dist/functions/index.js +0 -9
- package/dist/functions/read_csv.js +0 -53
- package/dist/functions/read_json.js +0 -21
- package/dist/functions/transpose.d.ts +0 -7
- package/dist/functions/transpose.js +0 -84
- package/dist/types.js +0 -2
- package/dist/utils/boolean.d.ts +0 -1
- package/dist/utils/boolean.js +0 -18
- package/dist/utils/csv.js +0 -313
- package/dist/utils/date.js +0 -348
- package/dist/utils/guards.d.ts +0 -12
- package/dist/utils/guards.js +0 -112
- package/dist/utils/index.js +0 -23
- package/dist/utils/json.js +0 -217
- package/dist/utils/list.js +0 -361
- package/dist/utils/number.js +0 -401
- package/dist/utils/string.js +0 -209
|
@@ -1,16 +1,86 @@
|
|
|
1
1
|
import { ExprBase } from "../ExprBase";
|
|
2
2
|
import type { IntoExpr, IExpr } from "../../types";
|
|
3
|
+
/**
|
|
4
|
+
* @namespace $df.col.struct
|
|
5
|
+
* @category ColumnExpression
|
|
6
|
+
* @syntax $df.col(<column_name>).struct.{symbol}(...)
|
|
7
|
+
*/
|
|
3
8
|
export declare class StructExprNamespace {
|
|
4
9
|
expr: IExpr;
|
|
5
10
|
constructor(expr: IExpr);
|
|
11
|
+
/**
|
|
12
|
+
* Extracts a sub-field property value from nested objects/struct columns.
|
|
13
|
+
* @param name Name of the field key to extract.
|
|
14
|
+
* @returns ColumnExpression
|
|
15
|
+
* @example
|
|
16
|
+
* >>> const df = $df.data({ user: [{ name: "Alice", id: 1 }] })
|
|
17
|
+
* >>> df.with_columns($df.col("user").struct.field("name").alias("user_name"))
|
|
18
|
+
* shape: (1, 2)
|
|
19
|
+
* ┌─────────────────────────┬───────────┐
|
|
20
|
+
* │ user │ user_name │
|
|
21
|
+
* ├─────────────────────────┼───────────┤
|
|
22
|
+
* │ { name: "Alice", id: 1 }│ Alice │
|
|
23
|
+
* └─────────────────────────┴───────────┘
|
|
24
|
+
*/
|
|
6
25
|
field(name: string): IExpr;
|
|
26
|
+
/**
|
|
27
|
+
* Renames existing field keys inside structured object columns.
|
|
28
|
+
* @param mapping Key-value map of current field names to new field names.
|
|
29
|
+
* @returns ColumnExpression
|
|
30
|
+
* @example
|
|
31
|
+
* >>> const df = $df.data({ user: [{ first: "Alice" }] })
|
|
32
|
+
* >>> df.with_columns($df.col("user").struct.rename_fields({ first: "first_name" }).alias("user_renamed"))
|
|
33
|
+
* shape: (1, 2)
|
|
34
|
+
* ┌───────────────────┬─────────────────────────┐
|
|
35
|
+
* │ user │ user_renamed │
|
|
36
|
+
* ├───────────────────┼─────────────────────────┤
|
|
37
|
+
* │ { first: "Alice" }│ { first_name: "Alice" } │
|
|
38
|
+
* └───────────────────┴─────────────────────────┘
|
|
39
|
+
*/
|
|
7
40
|
rename_fields(mapping: Record<string, string>): IExpr;
|
|
41
|
+
/**
|
|
42
|
+
* Inserts or updates fields inside structured object columns.
|
|
43
|
+
* @param fields Expressions or field map defining new or updated fields.
|
|
44
|
+
* @returns ColumnExpression
|
|
45
|
+
* @throws {Error} If expressions passed without an alias or name.
|
|
46
|
+
* @example
|
|
47
|
+
* >>> const df = $df.data({ user: [{ name: "Alice" }], age: [30] })
|
|
48
|
+
* >>> df.with_columns($df.col("user").struct.with_fields({ user_age: $df.col("age") }).alias("updated_user"))
|
|
49
|
+
* shape: (1, 3)
|
|
50
|
+
* ┌─────────────────┬─────┬───────────────────────────────┐
|
|
51
|
+
* │ user │ age │ updated_user │
|
|
52
|
+
* ├─────────────────┼─────┼───────────────────────────────┤
|
|
53
|
+
* │ { name: "Alice"}│ 30 │ { name: "Alice", user_age: 30}│
|
|
54
|
+
* └─────────────────┴─────┴───────────────────────────────┘
|
|
55
|
+
*/
|
|
8
56
|
with_fields(fields: IntoExpr[] | Record<string, IntoExpr>): IExpr;
|
|
57
|
+
/**
|
|
58
|
+
* Expands nested struct attributes into distinct columns in the DataFrame schema.
|
|
59
|
+
* @returns ColumnExpression
|
|
60
|
+
* @example
|
|
61
|
+
* >>> const df = $df.data({ user: [{ name: "Alice", age: 30 }] })
|
|
62
|
+
* >>> df.select($df.col("user").struct.unnest())
|
|
63
|
+
* shape: (1, 2)
|
|
64
|
+
* ┌───────┬─────┐
|
|
65
|
+
* │ name │ age │
|
|
66
|
+
* ├───────┼─────┤
|
|
67
|
+
* │ Alice │ 30 │
|
|
68
|
+
* └───────┴─────┘
|
|
69
|
+
*/
|
|
9
70
|
unnest(): IExpr;
|
|
10
71
|
}
|
|
11
72
|
export interface StructExprNamespace {
|
|
12
73
|
[key: string]: any;
|
|
13
74
|
}
|
|
14
75
|
export declare class StructExpr extends ExprBase {
|
|
76
|
+
/**
|
|
77
|
+
* Struct namespace accessor for operating on nested object/struct columns.
|
|
78
|
+
* @namespace $df.col
|
|
79
|
+
* @category ColumnExpression
|
|
80
|
+
* @syntax $df.col(<column_name>).struct
|
|
81
|
+
* @returns StructExprNamespace
|
|
82
|
+
* @example
|
|
83
|
+
* >>> df.select($df.col("user").struct.field("name"))
|
|
84
|
+
*/
|
|
15
85
|
get struct(): StructExprNamespace;
|
|
16
86
|
}
|
|
@@ -1,43 +1,569 @@
|
|
|
1
|
-
import type { TimeUnit } from "../../types";
|
|
1
|
+
import type { TimeUnit, StrftimeOptions, IsBusinessDayOptions, BusinessDayOffsetOptions, UtcOffsetOptions } from "../../types";
|
|
2
2
|
import { ExprBase } from "../ExprBase";
|
|
3
|
+
/**
|
|
4
|
+
* @namespace $df.col.dt
|
|
5
|
+
* @category ColumnExpression
|
|
6
|
+
* @syntax $df.col(<column_name>).dt.{symbol}(...)
|
|
7
|
+
*/
|
|
3
8
|
export declare class DateTimeExprNamespace {
|
|
4
9
|
expr: any;
|
|
5
10
|
constructor(expr: any);
|
|
6
11
|
_deriveDate(fn: (d: Date) => any): any;
|
|
7
12
|
_deriveDuration(fn: (v: number) => number): any;
|
|
13
|
+
/**
|
|
14
|
+
* Extracts century index of a Datetime value.
|
|
15
|
+
* @returns ColumnExpression
|
|
16
|
+
* @example
|
|
17
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
18
|
+
* >>> df.with_columns($df.col("d").dt.century().alias("century"))
|
|
19
|
+
* shape: (1, 2)
|
|
20
|
+
* ┌────────────┬─────────┐
|
|
21
|
+
* │ d │ century │
|
|
22
|
+
* ├────────────┼─────────┤
|
|
23
|
+
* │ 2026-05-20 │ 21 │
|
|
24
|
+
* └────────────┴─────────┘
|
|
25
|
+
*/
|
|
8
26
|
century(): any;
|
|
27
|
+
/**
|
|
28
|
+
* Extracts Date object component from Datetime.
|
|
29
|
+
* @returns ColumnExpression
|
|
30
|
+
* @example
|
|
31
|
+
* >>> const df = $df.data({ ts: ["2026-05-20T10:30:00Z"] })
|
|
32
|
+
* >>> df.with_columns($df.col("ts").dt.date().alias("date_only"))
|
|
33
|
+
* shape: (1, 2)
|
|
34
|
+
* ┌──────────────────────┬──────────────────────────┐
|
|
35
|
+
* │ ts │ date_only │
|
|
36
|
+
* ├──────────────────────┼──────────────────────────┤
|
|
37
|
+
* │ 2026-05-20T10:30:00Z │ 2026-05-20T00:00:00.000Z │
|
|
38
|
+
* └──────────────────────┴──────────────────────────┘
|
|
39
|
+
*/
|
|
9
40
|
date(): any;
|
|
10
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Extracts the calendar day component (1-31) from a Datetime column.
|
|
43
|
+
* @returns ColumnExpression
|
|
44
|
+
* @example
|
|
45
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
46
|
+
* >>> df.with_columns($df.col("d").dt.day().alias("day"))
|
|
47
|
+
* shape: (1, 2)
|
|
48
|
+
* ┌────────────┬─────┐
|
|
49
|
+
* │ d │ day │
|
|
50
|
+
* ├────────────┼─────┤
|
|
51
|
+
* │ 2026-05-20 │ 20 │
|
|
52
|
+
* └────────────┴─────┘
|
|
53
|
+
*/
|
|
11
54
|
day(): any;
|
|
55
|
+
/**
|
|
56
|
+
* Extracts number of days in the month.
|
|
57
|
+
* @returns ColumnExpression
|
|
58
|
+
* @example
|
|
59
|
+
* >>> const df = $df.data({ d: ["2024-02-15"] })
|
|
60
|
+
* >>> df.with_columns($df.col("d").dt.days_in_month().alias("dim"))
|
|
61
|
+
* shape: (1, 2)
|
|
62
|
+
* ┌────────────┬─────┐
|
|
63
|
+
* │ d │ dim │
|
|
64
|
+
* ├────────────┼─────┤
|
|
65
|
+
* │ 2024-02-15 │ 29 │
|
|
66
|
+
* └────────────┴─────┘
|
|
67
|
+
*/
|
|
68
|
+
days_in_month(): any;
|
|
69
|
+
/**
|
|
70
|
+
* Returns epoch duration timestamp offset.
|
|
71
|
+
* @param unit Time resolution unit ("ms", "us", "ns", "s").
|
|
72
|
+
* @returns ColumnExpression
|
|
73
|
+
* @example
|
|
74
|
+
* >>> const df = $df.data({ d: ["2026-01-01T00:00:00Z"] })
|
|
75
|
+
* >>> df.with_columns($df.col("d").dt.epoch("s").alias("epoch_s"))
|
|
76
|
+
* shape: (1, 2)
|
|
77
|
+
* ┌──────────────────────┬────────────┐
|
|
78
|
+
* │ d │ epoch_s │
|
|
79
|
+
* ├──────────────────────┼────────────┤
|
|
80
|
+
* │ 2026-01-01T00:00:00Z │ 1767225600 │
|
|
81
|
+
* └──────────────────────┴────────────┘
|
|
82
|
+
*/
|
|
12
83
|
epoch(unit?: TimeUnit): any;
|
|
84
|
+
/**
|
|
85
|
+
* Extracts the hour component (0-23) from a Datetime column.
|
|
86
|
+
* @returns ColumnExpression
|
|
87
|
+
* @example
|
|
88
|
+
* >>> const df = $df.data({ ts: ["2026-05-20T14:30:00Z"] })
|
|
89
|
+
* >>> df.with_columns($df.col("ts").dt.hour().alias("hr"))
|
|
90
|
+
* shape: (1, 2)
|
|
91
|
+
* ┌──────────────────────┬────┐
|
|
92
|
+
* │ ts │ hr │
|
|
93
|
+
* ├──────────────────────┼────┤
|
|
94
|
+
* │ 2026-05-20T14:30:00Z │ 14 │
|
|
95
|
+
* └──────────────────────┴────┘
|
|
96
|
+
*/
|
|
13
97
|
hour(): any;
|
|
98
|
+
/**
|
|
99
|
+
* Boolean check: Returns true if target falls on a business day.
|
|
100
|
+
* @param options Config options including custom weekend or holiday definitions.
|
|
101
|
+
* @returns ColumnExpression
|
|
102
|
+
* @example
|
|
103
|
+
* >>> const df = $df.data({ d: ["2026-05-18"] })
|
|
104
|
+
* >>> df.with_columns($df.col("d").dt.is_business_day().alias("is_bday"))
|
|
105
|
+
* shape: (1, 2)
|
|
106
|
+
* ┌────────────┬─────────┐
|
|
107
|
+
* │ d │ is_bday │
|
|
108
|
+
* ├────────────┼─────────┤
|
|
109
|
+
* │ 2026-05-18 │ true │
|
|
110
|
+
* └────────────┴─────────┘
|
|
111
|
+
*/
|
|
112
|
+
is_business_day(options?: IsBusinessDayOptions): any;
|
|
113
|
+
/**
|
|
114
|
+
* Checks if year is a leap year.
|
|
115
|
+
* @returns ColumnExpression
|
|
116
|
+
* @example
|
|
117
|
+
* >>> const df = $df.data({ d: ["2024-01-01", "2026-01-01"] })
|
|
118
|
+
* >>> df.with_columns($df.col("d").dt.is_leap_year().alias("leap"))
|
|
119
|
+
* shape: (2, 2)
|
|
120
|
+
* ┌────────────┬───────┐
|
|
121
|
+
* │ d │ leap │
|
|
122
|
+
* ├────────────┼───────┤
|
|
123
|
+
* │ 2024-01-01 │ true │
|
|
124
|
+
* │ 2026-01-01 │ false │
|
|
125
|
+
* └────────────┴───────┘
|
|
126
|
+
*/
|
|
14
127
|
is_leap_year(): any;
|
|
128
|
+
/**
|
|
129
|
+
* Extracts ISO week index.
|
|
130
|
+
* @returns ColumnExpression
|
|
131
|
+
* @example
|
|
132
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
133
|
+
* >>> df.with_columns($df.col("d").dt.iso_week().alias("week"))
|
|
134
|
+
* shape: (1, 2)
|
|
135
|
+
* ┌────────────┬──────┐
|
|
136
|
+
* │ d │ week │
|
|
137
|
+
* ├────────────┼──────┤
|
|
138
|
+
* │ 2026-05-20 │ 21 │
|
|
139
|
+
* └────────────┴──────┘
|
|
140
|
+
*/
|
|
141
|
+
iso_week(): any;
|
|
142
|
+
/**
|
|
143
|
+
* Extracts ISO calendar year.
|
|
144
|
+
* @returns ColumnExpression
|
|
145
|
+
* @example
|
|
146
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
147
|
+
* >>> df.with_columns($df.col("d").dt.iso_year().alias("iso_yr"))
|
|
148
|
+
* shape: (1, 2)
|
|
149
|
+
* ┌────────────┬────────┐
|
|
150
|
+
* │ d │ iso_yr │
|
|
151
|
+
* ├────────────┼────────┤
|
|
152
|
+
* │ 2026-05-20 │ 2026 │
|
|
153
|
+
* └────────────┴────────┘
|
|
154
|
+
*/
|
|
155
|
+
iso_year(): any;
|
|
156
|
+
/**
|
|
157
|
+
* Extracts microseconds component.
|
|
158
|
+
* @returns ColumnExpression
|
|
159
|
+
* @example
|
|
160
|
+
* >>> const df = $df.data({ ts: ["2026-05-20T10:00:00.123Z"] })
|
|
161
|
+
* >>> df.with_columns($df.col("ts").dt.microsecond().alias("us"))
|
|
162
|
+
* shape: (1, 2)
|
|
163
|
+
* ┌──────────────────────────┬────────┐
|
|
164
|
+
* │ ts │ us │
|
|
165
|
+
* ├──────────────────────────┼────────┤
|
|
166
|
+
* │ 2026-05-20T10:00:00.123Z │ 123000 │
|
|
167
|
+
* └──────────────────────────┴────────┘
|
|
168
|
+
*/
|
|
15
169
|
microsecond(): any;
|
|
170
|
+
/**
|
|
171
|
+
* Extracts millennium component index.
|
|
172
|
+
* @returns ColumnExpression
|
|
173
|
+
* @example
|
|
174
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
175
|
+
* >>> df.with_columns($df.col("d").dt.millennium().alias("mil"))
|
|
176
|
+
* shape: (1, 2)
|
|
177
|
+
* ┌────────────┬─────┐
|
|
178
|
+
* │ d │ mil │
|
|
179
|
+
* ├────────────┼─────┤
|
|
180
|
+
* │ 2026-05-20 │ 3 │
|
|
181
|
+
* └────────────┴─────┘
|
|
182
|
+
*/
|
|
16
183
|
millennium(): any;
|
|
184
|
+
/**
|
|
185
|
+
* Extracts milliseconds component.
|
|
186
|
+
* @returns ColumnExpression
|
|
187
|
+
* @example
|
|
188
|
+
* >>> const df = $df.data({ ts: ["2026-05-20T10:00:00.456Z"] })
|
|
189
|
+
* >>> df.with_columns($df.col("ts").dt.millisecond().alias("ms"))
|
|
190
|
+
* shape: (1, 2)
|
|
191
|
+
* ┌──────────────────────────┬─────┐
|
|
192
|
+
* │ ts │ ms │
|
|
193
|
+
* ├──────────────────────────┼─────┤
|
|
194
|
+
* │ 2026-05-20T10:00:00.456Z │ 456 │
|
|
195
|
+
* └──────────────────────────┴─────┘
|
|
196
|
+
*/
|
|
17
197
|
millisecond(): any;
|
|
198
|
+
/**
|
|
199
|
+
* Extracts the minute component (0-59) from a Datetime column.
|
|
200
|
+
* @returns ColumnExpression
|
|
201
|
+
* @example
|
|
202
|
+
* >>> const df = $df.data({ ts: ["2026-05-20T10:45:00Z"] })
|
|
203
|
+
* >>> df.with_columns($df.col("ts").dt.minute().alias("min"))
|
|
204
|
+
* shape: (1, 2)
|
|
205
|
+
* ┌──────────────────────┬─────┐
|
|
206
|
+
* │ ts │ min │
|
|
207
|
+
* ├──────────────────────┼─────┤
|
|
208
|
+
* │ 2026-05-20T10:45:00Z │ 45 │
|
|
209
|
+
* └──────────────────────┴─────┘
|
|
210
|
+
*/
|
|
18
211
|
minute(): any;
|
|
212
|
+
/**
|
|
213
|
+
* Extracts the calendar month component (1-12) from a Datetime column.
|
|
214
|
+
* @returns ColumnExpression
|
|
215
|
+
* @example
|
|
216
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
217
|
+
* >>> df.with_columns($df.col("d").dt.month().alias("m"))
|
|
218
|
+
* shape: (1, 2)
|
|
219
|
+
* ┌────────────┬───┐
|
|
220
|
+
* │ d │ m │
|
|
221
|
+
* ├────────────┼───┤
|
|
222
|
+
* │ 2026-05-20 │ 5 │
|
|
223
|
+
* └────────────┴───┘
|
|
224
|
+
*/
|
|
19
225
|
month(): any;
|
|
226
|
+
/**
|
|
227
|
+
* Returns date representing end of the month.
|
|
228
|
+
* @returns ColumnExpression
|
|
229
|
+
* @example
|
|
230
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
231
|
+
* >>> df.with_columns($df.col("d").dt.month_end().alias("m_end"))
|
|
232
|
+
* shape: (1, 2)
|
|
233
|
+
* ┌────────────┬──────────────────────────┐
|
|
234
|
+
* │ d │ m_end │
|
|
235
|
+
* ├────────────┼──────────────────────────┤
|
|
236
|
+
* │ 2026-05-20 │ 2026-05-31T00:00:00.000Z │
|
|
237
|
+
* └────────────┴──────────────────────────┘
|
|
238
|
+
*/
|
|
20
239
|
month_end(): any;
|
|
240
|
+
/**
|
|
241
|
+
* Returns date representing start of the month.
|
|
242
|
+
* @returns ColumnExpression
|
|
243
|
+
* @example
|
|
244
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
245
|
+
* >>> df.with_columns($df.col("d").dt.month_start().alias("m_start"))
|
|
246
|
+
* shape: (1, 2)
|
|
247
|
+
* ┌────────────┬──────────────────────────┐
|
|
248
|
+
* │ d │ m_start │
|
|
249
|
+
* ├────────────┼──────────────────────────┤
|
|
250
|
+
* │ 2026-05-20 │ 2026-05-01T00:00:00.000Z │
|
|
251
|
+
* └────────────┴──────────────────────────┘
|
|
252
|
+
*/
|
|
21
253
|
month_start(): any;
|
|
254
|
+
/**
|
|
255
|
+
* Extracts nanoseconds component.
|
|
256
|
+
* @returns ColumnExpression
|
|
257
|
+
* @example
|
|
258
|
+
* >>> const df = $df.data({ ts: ["2026-05-20T10:00:00.001Z"] })
|
|
259
|
+
* >>> df.with_columns($df.col("ts").dt.nanosecond().alias("ns"))
|
|
260
|
+
* shape: (1, 2)
|
|
261
|
+
* ┌──────────────────────────┬─────────┐
|
|
262
|
+
* │ ts │ ns │
|
|
263
|
+
* ├──────────────────────────┼─────────┤
|
|
264
|
+
* │ 2026-05-20T10:00:00.001Z │ 1000000 │
|
|
265
|
+
* └──────────────────────────┴─────────┘
|
|
266
|
+
*/
|
|
22
267
|
nanosecond(): any;
|
|
268
|
+
/**
|
|
269
|
+
* Offsets date by N business days.
|
|
270
|
+
* @param n Number of business days to offset.
|
|
271
|
+
* @param options Business day rules and holidays options.
|
|
272
|
+
* @returns ColumnExpression
|
|
273
|
+
* @example
|
|
274
|
+
* >>> const df = $df.data({ d: ["2026-05-15"] })
|
|
275
|
+
* >>> df.with_columns($df.col("d").dt.offset_business_day(2).alias("next_bday"))
|
|
276
|
+
* shape: (1, 2)
|
|
277
|
+
* ┌────────────┬──────────────────────────┐
|
|
278
|
+
* │ d │ next_bday │
|
|
279
|
+
* ├────────────┼──────────────────────────┤
|
|
280
|
+
* │ 2026-05-15 │ 2026-05-19T00:00:00.000Z │
|
|
281
|
+
* └────────────┴──────────────────────────┘
|
|
282
|
+
*/
|
|
283
|
+
offset_business_day(n: number | any, { excludeWeekdays, ...options }?: BusinessDayOffsetOptions): any;
|
|
284
|
+
/**
|
|
285
|
+
* Offsets date by N calendar days.
|
|
286
|
+
* @param n Number of calendar days to offset.
|
|
287
|
+
* @param options Offset options.
|
|
288
|
+
* @returns ColumnExpression
|
|
289
|
+
* @example
|
|
290
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
291
|
+
* >>> df.with_columns($df.col("d").dt.offset_day(5).alias("later"))
|
|
292
|
+
* shape: (1, 2)
|
|
293
|
+
* ┌────────────┬──────────────────────────┐
|
|
294
|
+
* │ d │ later │
|
|
295
|
+
* ├────────────┼──────────────────────────┤
|
|
296
|
+
* │ 2026-05-20 │ 2026-05-25T00:00:00.000Z │
|
|
297
|
+
* └────────────┴──────────────────────────┘
|
|
298
|
+
*/
|
|
299
|
+
offset_day(n: number | any, options?: BusinessDayOffsetOptions): any;
|
|
300
|
+
/**
|
|
301
|
+
* Returns day of the year (1-366).
|
|
302
|
+
* @returns ColumnExpression
|
|
303
|
+
* @example
|
|
304
|
+
* >>> const df = $df.data({ d: ["2026-02-01"] })
|
|
305
|
+
* >>> df.with_columns($df.col("d").dt.ordinal_day().alias("doy"))
|
|
306
|
+
* shape: (1, 2)
|
|
307
|
+
* ┌────────────┬─────┐
|
|
308
|
+
* │ d │ doy │
|
|
309
|
+
* ├────────────┼─────┤
|
|
310
|
+
* │ 2026-02-01 │ 32 │
|
|
311
|
+
* └────────────┴─────┘
|
|
312
|
+
*/
|
|
23
313
|
ordinal_day(): any;
|
|
314
|
+
/**
|
|
315
|
+
* Returns quarter of the year (1-4).
|
|
316
|
+
* @returns ColumnExpression
|
|
317
|
+
* @example
|
|
318
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
319
|
+
* >>> df.with_columns($df.col("d").dt.quarter().alias("qtr"))
|
|
320
|
+
* shape: (1, 2)
|
|
321
|
+
* ┌────────────┬─────┐
|
|
322
|
+
* │ d │ qtr │
|
|
323
|
+
* ├────────────┼─────┤
|
|
324
|
+
* │ 2026-05-20 │ 2 │
|
|
325
|
+
* └────────────┴─────┘
|
|
326
|
+
*/
|
|
24
327
|
quarter(): any;
|
|
328
|
+
/**
|
|
329
|
+
* Extracts seconds component (0-59).
|
|
330
|
+
* @returns ColumnExpression
|
|
331
|
+
* @example
|
|
332
|
+
* >>> const df = $df.data({ ts: ["2026-05-20T10:00:45Z"] })
|
|
333
|
+
* >>> df.with_columns($df.col("ts").dt.second().alias("sec"))
|
|
334
|
+
* shape: (1, 2)
|
|
335
|
+
* ┌──────────────────────┬─────┐
|
|
336
|
+
* │ ts │ sec │
|
|
337
|
+
* ├──────────────────────┼─────┤
|
|
338
|
+
* │ 2026-05-20T10:00:45Z │ 45 │
|
|
339
|
+
* └──────────────────────┴─────┘
|
|
340
|
+
*/
|
|
25
341
|
second(): any;
|
|
26
|
-
|
|
342
|
+
/**
|
|
343
|
+
* Formats dates to custom strings using strftime format tokens.
|
|
344
|
+
* @param options Formatting pattern configuration.
|
|
345
|
+
* @returns ColumnExpression
|
|
346
|
+
* @example
|
|
347
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
348
|
+
* >>> df.with_columns($df.col("d").dt.strftime("%Y/%m/%d").alias("formatted"))
|
|
349
|
+
* shape: (1, 2)
|
|
350
|
+
* ┌────────────┬────────────┐
|
|
351
|
+
* │ d │ formatted │
|
|
352
|
+
* ├────────────┼────────────┤
|
|
353
|
+
* │ 2026-05-20 │ 2026/05/20 │
|
|
354
|
+
* └────────────┴────────────┘
|
|
355
|
+
*/
|
|
356
|
+
strftime(options: StrftimeOptions): any;
|
|
357
|
+
/**
|
|
358
|
+
* Extracts time component string ("HH:MM:SS.mmm").
|
|
359
|
+
* @returns ColumnExpression
|
|
360
|
+
* @example
|
|
361
|
+
* >>> const df = $df.data({ ts: ["2026-05-20T10:30:00Z"] })
|
|
362
|
+
* >>> df.with_columns($df.col("ts").dt.time().alias("time"))
|
|
363
|
+
* shape: (1, 2)
|
|
364
|
+
* ┌──────────────────────┬──────────────┐
|
|
365
|
+
* │ ts │ time │
|
|
366
|
+
* ├──────────────────────┼──────────────┤
|
|
367
|
+
* │ 2026-05-20T10:30:00Z │ 10:30:00.000 │
|
|
368
|
+
* └──────────────────────┴──────────────┘
|
|
369
|
+
*/
|
|
27
370
|
time(): any;
|
|
371
|
+
/**
|
|
372
|
+
* Returns numeric timestamp relative to Epoch. Alias for epoch.
|
|
373
|
+
* @param unit Time unit resolution.
|
|
374
|
+
* @returns ColumnExpression
|
|
375
|
+
* @example
|
|
376
|
+
* >>> const df = $df.data({ d: ["2026-01-01T00:00:00Z"] })
|
|
377
|
+
* >>> df.with_columns($df.col("d").dt.timestamp("s").alias("ts"))
|
|
378
|
+
* shape: (1, 2)
|
|
379
|
+
* ┌──────────────────────┬────────────┐
|
|
380
|
+
* │ d │ ts │
|
|
381
|
+
* ├──────────────────────┼────────────┤
|
|
382
|
+
* │ 2026-01-01T00:00:00Z │ 1767225600 │
|
|
383
|
+
* └──────────────────────┴────────────┘
|
|
384
|
+
*/
|
|
28
385
|
timestamp(unit?: TimeUnit): any;
|
|
29
|
-
|
|
386
|
+
/**
|
|
387
|
+
* Formats dates to custom strings. Alias for strftime.
|
|
388
|
+
* @param options Formatting configuration.
|
|
389
|
+
* @returns ColumnExpression
|
|
390
|
+
* @example
|
|
391
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
392
|
+
* >>> df.with_columns($df.col("d").dt.to_string("%Y-%m-%d").alias("str"))
|
|
393
|
+
* shape: (1, 2)
|
|
394
|
+
* ┌────────────┬────────────┐
|
|
395
|
+
* │ d │ str │
|
|
396
|
+
* ├────────────┼────────────┤
|
|
397
|
+
* │ 2026-05-20 │ 2026-05-20 │
|
|
398
|
+
* └────────────┴────────────┘
|
|
399
|
+
*/
|
|
400
|
+
to_string(options: StrftimeOptions): any;
|
|
401
|
+
/**
|
|
402
|
+
* Converts Duration to integer day count.
|
|
403
|
+
* @returns ColumnExpression
|
|
404
|
+
* @example
|
|
405
|
+
* >>> const df = $df.data({ dur: [86400000] })
|
|
406
|
+
* >>> df.with_columns($df.col("dur").dt.total_days().alias("days"))
|
|
407
|
+
* shape: (1, 2)
|
|
408
|
+
* ┌──────────┬──────┐
|
|
409
|
+
* │ dur │ days │
|
|
410
|
+
* ├──────────┼──────┤
|
|
411
|
+
* │ 86400000 │ 1 │
|
|
412
|
+
* └──────────┴──────┘
|
|
413
|
+
*/
|
|
30
414
|
total_days(): any;
|
|
415
|
+
/**
|
|
416
|
+
* Converts Duration to floating point hours.
|
|
417
|
+
* @returns ColumnExpression
|
|
418
|
+
* @example
|
|
419
|
+
* >>> const df = $df.data({ dur: [3600000] })
|
|
420
|
+
* >>> df.with_columns($df.col("dur").dt.total_hours().alias("hrs"))
|
|
421
|
+
* shape: (1, 2)
|
|
422
|
+
* ┌─────────┬─────┐
|
|
423
|
+
* │ dur │ hrs │
|
|
424
|
+
* ├─────────┼─────┤
|
|
425
|
+
* │ 3600000 │ 1 │
|
|
426
|
+
* └─────────┴─────┘
|
|
427
|
+
*/
|
|
31
428
|
total_hours(): any;
|
|
429
|
+
/**
|
|
430
|
+
* Converts Duration to microsecond count.
|
|
431
|
+
* @returns ColumnExpression
|
|
432
|
+
* @example
|
|
433
|
+
* >>> const df = $df.data({ dur: [10] })
|
|
434
|
+
* >>> df.with_columns($df.col("dur").dt.total_microseconds().alias("us"))
|
|
435
|
+
* shape: (1, 2)
|
|
436
|
+
* ┌─────┬───────┐
|
|
437
|
+
* │ dur │ us │
|
|
438
|
+
* ├─────┼───────┤
|
|
439
|
+
* │ 10 │ 10000 │
|
|
440
|
+
* └─────┴───────┘
|
|
441
|
+
*/
|
|
32
442
|
total_microseconds(): any;
|
|
443
|
+
/**
|
|
444
|
+
* Converts Duration to millisecond count.
|
|
445
|
+
* @returns ColumnExpression
|
|
446
|
+
* @example
|
|
447
|
+
* >>> const df = $df.data({ dur: [500] })
|
|
448
|
+
* >>> df.with_columns($df.col("dur").dt.total_milliseconds().alias("ms"))
|
|
449
|
+
* shape: (1, 2)
|
|
450
|
+
* ┌─────┬─────┐
|
|
451
|
+
* │ dur │ ms │
|
|
452
|
+
* ├─────┼─────┤
|
|
453
|
+
* │ 500 │ 500 │
|
|
454
|
+
* └─────┴─────┘
|
|
455
|
+
*/
|
|
33
456
|
total_milliseconds(): any;
|
|
457
|
+
/**
|
|
458
|
+
* Converts Duration to floating point minutes.
|
|
459
|
+
* @returns ColumnExpression
|
|
460
|
+
* @example
|
|
461
|
+
* >>> const df = $df.data({ dur: [60000] })
|
|
462
|
+
* >>> df.with_columns($df.col("dur").dt.total_minutes().alias("mins"))
|
|
463
|
+
* shape: (1, 2)
|
|
464
|
+
* ┌───────┬──────┐
|
|
465
|
+
* │ dur │ mins │
|
|
466
|
+
* ├───────┼──────┤
|
|
467
|
+
* │ 60000 │ 1 │
|
|
468
|
+
* └───────┴──────┘
|
|
469
|
+
*/
|
|
34
470
|
total_minutes(): any;
|
|
471
|
+
/**
|
|
472
|
+
* Converts Duration to nanosecond count.
|
|
473
|
+
* @returns ColumnExpression
|
|
474
|
+
* @example
|
|
475
|
+
* >>> const df = $df.data({ dur: [1] })
|
|
476
|
+
* >>> df.with_columns($df.col("dur").dt.total_nanoseconds().alias("ns"))
|
|
477
|
+
* shape: (1, 2)
|
|
478
|
+
* ┌─────┬─────────┐
|
|
479
|
+
* │ dur │ ns │
|
|
480
|
+
* ├─────┼─────────┤
|
|
481
|
+
* │ 1 │ 1000000 │
|
|
482
|
+
* └─────┴─────────┘
|
|
483
|
+
*/
|
|
35
484
|
total_nanoseconds(): any;
|
|
485
|
+
/**
|
|
486
|
+
* Converts Duration to floating point seconds.
|
|
487
|
+
* @returns ColumnExpression
|
|
488
|
+
* @example
|
|
489
|
+
* >>> const df = $df.data({ dur: [1000] })
|
|
490
|
+
* >>> df.with_columns($df.col("dur").dt.total_seconds().alias("secs"))
|
|
491
|
+
* shape: (1, 2)
|
|
492
|
+
* ┌──────┬──────┐
|
|
493
|
+
* │ dur │ secs │
|
|
494
|
+
* ├──────┼──────┤
|
|
495
|
+
* │ 1000 │ 1 │
|
|
496
|
+
* └──────┴──────┘
|
|
497
|
+
*/
|
|
36
498
|
total_seconds(): any;
|
|
499
|
+
/**
|
|
500
|
+
* Returns the offset of local timezone relative to UTC in minutes.
|
|
501
|
+
* @param timeZone Target timezone string identifier.
|
|
502
|
+
* @param options Utc offset calculation options.
|
|
503
|
+
* @returns ColumnExpression
|
|
504
|
+
* @example
|
|
505
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
506
|
+
* >>> df.with_columns($df.col("d").dt.utc_offset("UTC").alias("offset"))
|
|
507
|
+
* shape: (1, 2)
|
|
508
|
+
* ┌────────────┬────────┐
|
|
509
|
+
* │ d │ offset │
|
|
510
|
+
* ├────────────┼────────┤
|
|
511
|
+
* │ 2026-05-20 │ 0 │
|
|
512
|
+
* └────────────┴────────┘
|
|
513
|
+
*/
|
|
514
|
+
utc_offset(timeZone?: string, options?: UtcOffsetOptions): any;
|
|
515
|
+
/**
|
|
516
|
+
* Extracts ISO week index. Alias for iso_week.
|
|
517
|
+
* @returns ColumnExpression
|
|
518
|
+
* @example
|
|
519
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
520
|
+
* >>> df.with_columns($df.col("d").dt.week().alias("week"))
|
|
521
|
+
* shape: (1, 2)
|
|
522
|
+
* ┌────────────┬──────┐
|
|
523
|
+
* │ d │ week │
|
|
524
|
+
* ├────────────┼──────┤
|
|
525
|
+
* │ 2026-05-20 │ 21 │
|
|
526
|
+
* └────────────┴──────┘
|
|
527
|
+
*/
|
|
37
528
|
week(): any;
|
|
529
|
+
/**
|
|
530
|
+
* Extracts weekday component (1=Monday, 7=Sunday).
|
|
531
|
+
* @returns ColumnExpression
|
|
532
|
+
* @example
|
|
533
|
+
* >>> const df = $df.data({ d: ["2026-05-18"] })
|
|
534
|
+
* >>> df.with_columns($df.col("d").dt.weekday().alias("wd"))
|
|
535
|
+
* shape: (1, 2)
|
|
536
|
+
* ┌────────────┬────┐
|
|
537
|
+
* │ d │ wd │
|
|
538
|
+
* ├────────────┼────┤
|
|
539
|
+
* │ 2026-05-18 │ 1 │
|
|
540
|
+
* └────────────┴────┘
|
|
541
|
+
*/
|
|
38
542
|
weekday(): any;
|
|
543
|
+
/**
|
|
544
|
+
* Extracts the year component from a Datetime column.
|
|
545
|
+
* @returns ColumnExpression
|
|
546
|
+
* @example
|
|
547
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
548
|
+
* >>> df.with_columns($df.col("d").dt.year().alias("yr"))
|
|
549
|
+
* shape: (1, 2)
|
|
550
|
+
* ┌────────────┬──────┐
|
|
551
|
+
* │ d │ yr │
|
|
552
|
+
* ├────────────┼──────┤
|
|
553
|
+
* │ 2026-05-20 │ 2026 │
|
|
554
|
+
* └────────────┴──────┘
|
|
555
|
+
*/
|
|
39
556
|
year(): any;
|
|
40
557
|
}
|
|
41
558
|
export declare class TemporalExpr extends ExprBase {
|
|
559
|
+
/**
|
|
560
|
+
* Datetime namespace accessor for date, time, and duration operations.
|
|
561
|
+
* @namespace $df.col
|
|
562
|
+
* @category ColumnExpression
|
|
563
|
+
* @syntax $df.col(<column_name>).dt
|
|
564
|
+
* @returns DateTimeExprNamespace
|
|
565
|
+
* @example
|
|
566
|
+
* >>> df.select($df.col("date").dt.year())
|
|
567
|
+
*/
|
|
42
568
|
get dt(): DateTimeExprNamespace;
|
|
43
569
|
}
|