df-script 1.9.0 → 2.0.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 +148 -235
- package/dist/api.d.ts +41 -36
- package/dist/columnExpressions/ColumnExpr.d.ts +5 -8
- package/dist/columnExpressions/functions/all.d.ts +13 -13
- package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
- package/dist/columnExpressions/functions/duration.d.ts +16 -21
- package/dist/columnExpressions/functions/element.d.ts +10 -10
- package/dist/columnExpressions/functions/exclude.d.ts +14 -14
- package/dist/columnExpressions/functions/implode.d.ts +7 -7
- package/dist/columnExpressions/functions/lit.d.ts +9 -9
- package/dist/columnExpressions/functions/seqRange.d.ts +69 -0
- package/dist/columnExpressions/functions/struct.d.ts +6 -6
- package/dist/columnExpressions/functions/when.d.ts +25 -28
- package/dist/columnExpressions/index.d.ts +3 -7
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +550 -221
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +701 -327
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +508 -212
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +398 -201
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +59 -29
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +23 -9
- package/dist/columnExpressions/mixins/StandardExpr.d.ts +3234 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +1163 -524
- package/dist/columnExpressions/mixins/StructExpr.d.ts +67 -25
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +518 -212
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +270 -102
- package/dist/columnExpressions/typeInference.d.ts +3 -3
- package/dist/columnExpressions/types.d.ts +5 -0
- package/dist/columnExpressions/utils.d.ts +7 -0
- package/dist/constants.d.ts +11 -2
- package/dist/dataframe/dataframe.d.ts +755 -592
- package/dist/dataframe/grouped/grouped.d.ts +24 -6
- package/dist/dataframe/grouped.d.ts +70 -0
- package/dist/dataframe/index.d.ts +1 -1
- package/dist/dataframe/lazy.d.ts +37 -0
- package/dist/dataframe/types.d.ts +46 -22
- package/dist/dataframe/utils.d.ts +10 -4
- package/dist/datatypes/index.d.ts +11 -4
- package/dist/expressions.js +1 -0
- package/dist/expressions.mjs +1 -0
- package/dist/functions/concat.d.ts +68 -16
- package/dist/functions/index.d.ts +2 -2
- package/dist/functions/readCsv.d.ts +35 -0
- package/dist/functions/readJson.d.ts +33 -0
- package/dist/index.js +5 -6
- package/dist/index.mjs +5 -6
- package/dist/types.d.ts +42 -9
- package/dist/utils/array.d.ts +17 -14
- package/dist/utils/csv.d.ts +4 -1
- package/dist/utils/date.d.ts +3 -19
- package/dist/utils/duration.d.ts +7 -5
- package/dist/utils/json.d.ts +5 -3
- package/dist/utils/object.d.ts +0 -18
- package/dist/utils/string.d.ts +5 -0
- package/dist/utils.js +4 -0
- package/dist/utils.mjs +4 -0
- package/package.json +29 -8
- package/dist/assets/index-DBhGK6Tp.css +0 -1
- package/dist/assets/index-DEJEV_tU.js +0 -195
- package/dist/index.html +0 -17
|
@@ -12,17 +12,17 @@ import { ExprBase } from "../ExprBase";
|
|
|
12
12
|
* as `microsecond()` and `nanosecond()` always scale from milliseconds. Migrating to
|
|
13
13
|
* raw `BigInt` arrays would be required for true sub-ms storage.
|
|
14
14
|
*
|
|
15
|
-
* _Timezone enforcement_: `
|
|
15
|
+
* _Timezone enforcement_: `convertTimeZone` can only validate that the column is
|
|
16
16
|
* timezone-aware when `_castType` is explicitly set within the expression chain
|
|
17
|
-
* (e.g. after `
|
|
17
|
+
* (e.g. after `castTimeUnit`). Enforcement against a column whose type is unknown
|
|
18
18
|
* at expression-build time requires schema-level checks in DataFrame operations.
|
|
19
19
|
*/
|
|
20
20
|
export declare class DateTimeExprNamespace {
|
|
21
21
|
expr: any;
|
|
22
22
|
constructor(expr: any);
|
|
23
|
-
/** Returns the column's schema timezone from a prior
|
|
23
|
+
/** Returns the column's schema timezone from a prior convertTimeZone call, or null. */
|
|
24
24
|
_colTz(): string | null;
|
|
25
|
-
/** Returns the column's schema time unit from a prior
|
|
25
|
+
/** Returns the column's schema time unit from a prior castTimeUnit call, or null. */
|
|
26
26
|
_colTu(): DatetimeTimeUnit | null;
|
|
27
27
|
_deriveDate(fn: (d: Date) => any): any;
|
|
28
28
|
/**
|
|
@@ -31,8 +31,15 @@ export declare class DateTimeExprNamespace {
|
|
|
31
31
|
* @param unit Target time unit: `"ms"` (milliseconds), `"us"` (microseconds), or `"ns"` (nanoseconds).
|
|
32
32
|
* @returns ColumnExpression
|
|
33
33
|
* @example
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
35
|
+
* >>> df
|
|
36
|
+
* shape: (1, 1)
|
|
37
|
+
* ┌──────────────────────────┐
|
|
38
|
+
* │ date │
|
|
39
|
+
* ├──────────────────────────┤
|
|
40
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
41
|
+
* └──────────────────────────┘
|
|
42
|
+
* >>> df.withColumns($df.col("ts").dt.castTimeUnit("us").alias("ts_us"))
|
|
36
43
|
* shape: (1, 2)
|
|
37
44
|
* ┌──────────────────────────┬──────────────────────────┐
|
|
38
45
|
* │ ts │ ts_us │
|
|
@@ -40,13 +47,20 @@ export declare class DateTimeExprNamespace {
|
|
|
40
47
|
* │ 2026-05-20T10:00:00.123Z │ 2026-05-20T10:00:00.123Z │
|
|
41
48
|
* └──────────────────────────┴──────────────────────────┘
|
|
42
49
|
*/
|
|
43
|
-
|
|
50
|
+
castTimeUnit(unit: DatetimeTimeUnit): any;
|
|
44
51
|
/**
|
|
45
52
|
* Extracts the 1-indexed century component (e.g. 21 for 2026) from a Datetime column.
|
|
46
53
|
* @returns ColumnExpression
|
|
47
54
|
* @example
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
56
|
+
* >>> df
|
|
57
|
+
* shape: (1, 1)
|
|
58
|
+
* ┌──────────────────────────┐
|
|
59
|
+
* │ date │
|
|
60
|
+
* ├──────────────────────────┤
|
|
61
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
62
|
+
* └──────────────────────────┘
|
|
63
|
+
* >>> df.withColumns($df.col("d").dt.century().alias("century"))
|
|
50
64
|
* shape: (1, 2)
|
|
51
65
|
* ┌────────────┬─────────┐
|
|
52
66
|
* │ d │ century │
|
|
@@ -54,38 +68,54 @@ export declare class DateTimeExprNamespace {
|
|
|
54
68
|
* │ 2026-05-20 │ 21 │
|
|
55
69
|
* └────────────┴─────────┘
|
|
56
70
|
*/
|
|
57
|
-
century(): any;
|
|
71
|
+
century(timeZone?: string): any;
|
|
58
72
|
/**
|
|
59
73
|
* Converts a Datetime column to a different IANA timezone.
|
|
60
74
|
* Preserves the exact UTC epoch instant while changing the timezone label, affecting
|
|
61
75
|
* how local wall-clock component extractors (`hour()`, `day()`, etc.) and `strftime` interpret values.
|
|
62
76
|
* Requires the column to already be timezone-aware; use `replace({ timeZone })`
|
|
63
77
|
* to assign a timezone to a naive column first.
|
|
78
|
+
* @note [Timezone Compatibility]: Converting across named timezones relies on native `Intl.DateTimeFormat`
|
|
79
|
+
* IANA database resolution. Unrecognized timezones safely fallback to `"UTC"`.
|
|
64
80
|
* @param timeZone Target IANA timezone identifier (e.g. `"UTC"`, `"America/New_York"`, `"Europe/London"`).
|
|
65
81
|
* @returns ColumnExpression
|
|
66
82
|
* @example
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
84
|
+
* >>> df
|
|
85
|
+
* shape: (1, 1)
|
|
86
|
+
* ┌──────────────────────────┐
|
|
87
|
+
* │ date │
|
|
88
|
+
* ├──────────────────────────┤
|
|
89
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
90
|
+
* └──────────────────────────┘
|
|
91
|
+
* >>> df.withColumns($df.col("ts").dt.replace({ timeZone: "UTC" }).dt.convertTimeZone("America/New_York").alias("ts_ny"))
|
|
69
92
|
* shape: (1, 2)
|
|
70
93
|
* ┌──────────────────────────┬───────────────────────────────┐
|
|
71
94
|
* │ ts │ ts_ny │
|
|
72
95
|
* ├──────────────────────────┼───────────────────────────────┤
|
|
73
|
-
* │ 2026-
|
|
96
|
+
* │ 2026-05-20T10:00:00.123Z │ 2026-05-20 06:00:00.123 EDT │
|
|
74
97
|
* └──────────────────────────┴───────────────────────────────┘
|
|
75
98
|
*/
|
|
76
|
-
|
|
99
|
+
convertTimeZone(timeZone: string): any;
|
|
77
100
|
/**
|
|
78
101
|
* Extracts the Date object component from a Datetime column, truncating time to 00:00:00.000 UTC.
|
|
79
102
|
* @returns ColumnExpression
|
|
80
103
|
* @example
|
|
81
|
-
|
|
82
|
-
|
|
104
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
105
|
+
* >>> df
|
|
106
|
+
* shape: (1, 1)
|
|
107
|
+
* ┌──────────────────────────┐
|
|
108
|
+
* │ date │
|
|
109
|
+
* ├──────────────────────────┤
|
|
110
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
111
|
+
* └──────────────────────────┘
|
|
112
|
+
* >>> df.withColumns($df.col("ts").dt.date().alias("date_only"))
|
|
83
113
|
* shape: (1, 2)
|
|
84
|
-
*
|
|
85
|
-
* │ ts
|
|
86
|
-
*
|
|
87
|
-
* │ 2026-05-20T10:
|
|
88
|
-
*
|
|
114
|
+
* ┌──────────────────────────┬──────────────────────────┐
|
|
115
|
+
* │ ts │ date_only │
|
|
116
|
+
* ├──────────────────────────┼──────────────────────────┤
|
|
117
|
+
* │ 2026-05-20T10:00:00.123Z │ 2026-05-20T00:00:00.000Z │
|
|
118
|
+
* └──────────────────────────┴──────────────────────────┘
|
|
89
119
|
*/
|
|
90
120
|
date(): any;
|
|
91
121
|
/**
|
|
@@ -93,8 +123,15 @@ export declare class DateTimeExprNamespace {
|
|
|
93
123
|
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
94
124
|
* @returns ColumnExpression
|
|
95
125
|
* @example
|
|
96
|
-
|
|
97
|
-
|
|
126
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
127
|
+
* >>> df
|
|
128
|
+
* shape: (1, 1)
|
|
129
|
+
* ┌──────────────────────────┐
|
|
130
|
+
* │ date │
|
|
131
|
+
* ├──────────────────────────┤
|
|
132
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
133
|
+
* └──────────────────────────┘
|
|
134
|
+
* >>> df.withColumns($df.col("d").dt.day().alias("day"))
|
|
98
135
|
* shape: (1, 2)
|
|
99
136
|
* ┌────────────┬─────┐
|
|
100
137
|
* │ d │ day │
|
|
@@ -108,29 +145,43 @@ export declare class DateTimeExprNamespace {
|
|
|
108
145
|
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
109
146
|
* @returns ColumnExpression
|
|
110
147
|
* @example
|
|
111
|
-
|
|
112
|
-
|
|
148
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
149
|
+
* >>> df
|
|
150
|
+
* shape: (1, 1)
|
|
151
|
+
* ┌──────────────────────────┐
|
|
152
|
+
* │ date │
|
|
153
|
+
* ├──────────────────────────┤
|
|
154
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
155
|
+
* └──────────────────────────┘
|
|
156
|
+
* >>> df.withColumns($df.col("d").dt.daysInMonth().alias("dim"))
|
|
113
157
|
* shape: (1, 2)
|
|
114
158
|
* ┌────────────┬─────┐
|
|
115
159
|
* │ d │ dim │
|
|
116
160
|
* ├────────────┼─────┤
|
|
117
|
-
* │
|
|
161
|
+
* │ 2026-05-20 │ 31 │
|
|
118
162
|
* └────────────┴─────┘
|
|
119
163
|
*/
|
|
120
|
-
|
|
164
|
+
daysInMonth(timeZone?: string): any;
|
|
121
165
|
/**
|
|
122
166
|
* Returns the epoch duration timestamp offset in the specified time resolution unit.
|
|
123
167
|
* @param unit Time resolution unit (`"ms"`, `"us"`, `"ns"`, `"s"`). Defaults to `"ms"`.
|
|
124
168
|
* @returns ColumnExpression
|
|
125
169
|
* @example
|
|
126
|
-
|
|
127
|
-
|
|
170
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
171
|
+
* >>> df
|
|
172
|
+
* shape: (1, 1)
|
|
173
|
+
* ┌──────────────────────────┐
|
|
174
|
+
* │ date │
|
|
175
|
+
* ├──────────────────────────┤
|
|
176
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
177
|
+
* └──────────────────────────┘
|
|
178
|
+
* >>> df.withColumns($df.col("d").dt.epoch("s").alias("epoch_s"))
|
|
128
179
|
* shape: (1, 2)
|
|
129
|
-
*
|
|
130
|
-
* │ d
|
|
131
|
-
*
|
|
132
|
-
* │ 2026-
|
|
133
|
-
*
|
|
180
|
+
* ┌────────────┬────────────┐
|
|
181
|
+
* │ d │ epoch_s │
|
|
182
|
+
* ├────────────┼────────────┤
|
|
183
|
+
* │ 2026-05-20 │ 1779235200 │
|
|
184
|
+
* └────────────┴────────────┘
|
|
134
185
|
*/
|
|
135
186
|
epoch(unit?: TimeUnit): any;
|
|
136
187
|
/**
|
|
@@ -138,14 +189,21 @@ export declare class DateTimeExprNamespace {
|
|
|
138
189
|
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
139
190
|
* @returns ColumnExpression
|
|
140
191
|
* @example
|
|
141
|
-
|
|
142
|
-
|
|
192
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
193
|
+
* >>> df
|
|
194
|
+
* shape: (1, 1)
|
|
195
|
+
* ┌──────────────────────────┐
|
|
196
|
+
* │ date │
|
|
197
|
+
* ├──────────────────────────┤
|
|
198
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
199
|
+
* └──────────────────────────┘
|
|
200
|
+
* >>> df.withColumns($df.col("ts").dt.hour().alias("hr"))
|
|
143
201
|
* shape: (1, 2)
|
|
144
|
-
*
|
|
145
|
-
* │ ts
|
|
146
|
-
*
|
|
147
|
-
* │ 2026-05-
|
|
148
|
-
*
|
|
202
|
+
* ┌──────────────────────────┬────┐
|
|
203
|
+
* │ ts │ hr │
|
|
204
|
+
* ├──────────────────────────┼────┤
|
|
205
|
+
* │ 2026-05-20T10:00:00.123Z │ 10 │
|
|
206
|
+
* └──────────────────────────┴────┘
|
|
149
207
|
*/
|
|
150
208
|
hour(timeZone?: string): any;
|
|
151
209
|
/**
|
|
@@ -154,37 +212,59 @@ export declare class DateTimeExprNamespace {
|
|
|
154
212
|
* @param options Business day rules and custom holiday configuration options.
|
|
155
213
|
* @returns ColumnExpression
|
|
156
214
|
* @example
|
|
157
|
-
|
|
158
|
-
|
|
215
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
216
|
+
* >>> df
|
|
217
|
+
* shape: (1, 1)
|
|
218
|
+
* ┌──────────────────────────┐
|
|
219
|
+
* │ date │
|
|
220
|
+
* ├──────────────────────────┤
|
|
221
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
222
|
+
* └──────────────────────────┘
|
|
223
|
+
* >>> df.withColumns($df.col("d").dt.isBusinessDay().alias("is_bday"))
|
|
159
224
|
* shape: (1, 2)
|
|
160
225
|
* ┌────────────┬─────────┐
|
|
161
226
|
* │ d │ is_bday │
|
|
162
227
|
* ├────────────┼─────────┤
|
|
163
|
-
* │ 2026-05-
|
|
228
|
+
* │ 2026-05-20 │ true │
|
|
164
229
|
* └────────────┴─────────┘
|
|
165
230
|
*/
|
|
166
|
-
|
|
231
|
+
isBusinessDay(options?: IsBusinessDayOptions): any;
|
|
167
232
|
/**
|
|
168
233
|
* Checks if the calendar year of a Datetime value is a leap year (366 days).
|
|
234
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
169
235
|
* @returns ColumnExpression
|
|
170
236
|
* @example
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
237
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
238
|
+
* >>> df
|
|
239
|
+
* shape: (1, 1)
|
|
240
|
+
* ┌──────────────────────────┐
|
|
241
|
+
* │ date │
|
|
242
|
+
* ├──────────────────────────┤
|
|
243
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
244
|
+
* └──────────────────────────┘
|
|
245
|
+
* >>> df.withColumns($df.col("d").dt.isLeapYear().alias("leap"))
|
|
246
|
+
* shape: (1, 2)
|
|
174
247
|
* ┌────────────┬───────┐
|
|
175
248
|
* │ d │ leap │
|
|
176
249
|
* ├────────────┼───────┤
|
|
177
|
-
* │
|
|
178
|
-
* │ 2026-01-01 │ false │
|
|
250
|
+
* │ 2026-05-20 │ false │
|
|
179
251
|
* └────────────┴───────┘
|
|
180
252
|
*/
|
|
181
|
-
|
|
253
|
+
isLeapYear(timeZone?: string): any;
|
|
182
254
|
/**
|
|
183
255
|
* Extracts the ISO 8601 week number (1-53) from a Datetime column.
|
|
256
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
184
257
|
* @returns ColumnExpression
|
|
185
258
|
* @example
|
|
186
|
-
|
|
187
|
-
|
|
259
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
260
|
+
* >>> df
|
|
261
|
+
* shape: (1, 1)
|
|
262
|
+
* ┌──────────────────────────┐
|
|
263
|
+
* │ date │
|
|
264
|
+
* ├──────────────────────────┤
|
|
265
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
266
|
+
* └──────────────────────────┘
|
|
267
|
+
* >>> df.withColumns($df.col("d").dt.isoWeek().alias("week"))
|
|
188
268
|
* shape: (1, 2)
|
|
189
269
|
* ┌────────────┬──────┐
|
|
190
270
|
* │ d │ week │
|
|
@@ -192,13 +272,21 @@ export declare class DateTimeExprNamespace {
|
|
|
192
272
|
* │ 2026-05-20 │ 21 │
|
|
193
273
|
* └────────────┴──────┘
|
|
194
274
|
*/
|
|
195
|
-
|
|
275
|
+
isoWeek(timeZone?: string): any;
|
|
196
276
|
/**
|
|
197
277
|
* Extracts the ISO 8601 week-numbering year from a Datetime column.
|
|
278
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
198
279
|
* @returns ColumnExpression
|
|
199
280
|
* @example
|
|
200
|
-
|
|
201
|
-
|
|
281
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
282
|
+
* >>> df
|
|
283
|
+
* shape: (1, 1)
|
|
284
|
+
* ┌──────────────────────────┐
|
|
285
|
+
* │ date │
|
|
286
|
+
* ├──────────────────────────┤
|
|
287
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
288
|
+
* └──────────────────────────┘
|
|
289
|
+
* >>> df.withColumns($df.col("d").dt.isoYear().alias("iso_yr"))
|
|
202
290
|
* shape: (1, 2)
|
|
203
291
|
* ┌────────────┬────────┐
|
|
204
292
|
* │ d │ iso_yr │
|
|
@@ -206,13 +294,21 @@ export declare class DateTimeExprNamespace {
|
|
|
206
294
|
* │ 2026-05-20 │ 2026 │
|
|
207
295
|
* └────────────┴────────┘
|
|
208
296
|
*/
|
|
209
|
-
|
|
297
|
+
isoYear(timeZone?: string): any;
|
|
210
298
|
/**
|
|
211
299
|
* Extracts the microsecond component (0-999,000) scaled from Datetime millisecond precision.
|
|
300
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
212
301
|
* @returns ColumnExpression
|
|
213
302
|
* @example
|
|
214
|
-
|
|
215
|
-
|
|
303
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
304
|
+
* >>> df
|
|
305
|
+
* shape: (1, 1)
|
|
306
|
+
* ┌──────────────────────────┐
|
|
307
|
+
* │ date │
|
|
308
|
+
* ├──────────────────────────┤
|
|
309
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
310
|
+
* └──────────────────────────┘
|
|
311
|
+
* >>> df.withColumns($df.col("ts").dt.microsecond().alias("us"))
|
|
216
312
|
* shape: (1, 2)
|
|
217
313
|
* ┌──────────────────────────┬────────┐
|
|
218
314
|
* │ ts │ us │
|
|
@@ -220,13 +316,20 @@ export declare class DateTimeExprNamespace {
|
|
|
220
316
|
* │ 2026-05-20T10:00:00.123Z │ 123000 │
|
|
221
317
|
* └──────────────────────────┴────────┘
|
|
222
318
|
*/
|
|
223
|
-
microsecond(): any;
|
|
319
|
+
microsecond(timeZone?: string): any;
|
|
224
320
|
/**
|
|
225
321
|
* Extracts the 1-indexed millennium component index (e.g. 3 for the year 2026) from a Datetime column.
|
|
226
322
|
* @returns ColumnExpression
|
|
227
323
|
* @example
|
|
228
|
-
|
|
229
|
-
|
|
324
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
325
|
+
* >>> df
|
|
326
|
+
* shape: (1, 1)
|
|
327
|
+
* ┌──────────────────────────┐
|
|
328
|
+
* │ date │
|
|
329
|
+
* ├──────────────────────────┤
|
|
330
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
331
|
+
* └──────────────────────────┘
|
|
332
|
+
* >>> df.withColumns($df.col("d").dt.millennium().alias("mil"))
|
|
230
333
|
* shape: (1, 2)
|
|
231
334
|
* ┌────────────┬─────┐
|
|
232
335
|
* │ d │ mil │
|
|
@@ -234,34 +337,49 @@ export declare class DateTimeExprNamespace {
|
|
|
234
337
|
* │ 2026-05-20 │ 3 │
|
|
235
338
|
* └────────────┴─────┘
|
|
236
339
|
*/
|
|
237
|
-
millennium(): any;
|
|
340
|
+
millennium(timeZone?: string): any;
|
|
238
341
|
/**
|
|
239
342
|
* Extracts the millisecond component (0-999) from a Datetime column.
|
|
343
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
240
344
|
* @returns ColumnExpression
|
|
241
345
|
* @example
|
|
242
|
-
|
|
243
|
-
|
|
346
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
347
|
+
* >>> df
|
|
348
|
+
* shape: (1, 1)
|
|
349
|
+
* ┌──────────────────────────┐
|
|
350
|
+
* │ date │
|
|
351
|
+
* ├──────────────────────────┤
|
|
352
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
353
|
+
* └──────────────────────────┘
|
|
354
|
+
* >>> df.withColumns($df.col("ts").dt.millisecond().alias("ms"))
|
|
244
355
|
* shape: (1, 2)
|
|
245
356
|
* ┌──────────────────────────┬─────┐
|
|
246
357
|
* │ ts │ ms │
|
|
247
358
|
* ├──────────────────────────┼─────┤
|
|
248
|
-
* │ 2026-05-20T10:00:00.
|
|
359
|
+
* │ 2026-05-20T10:00:00.123Z │ 123 │
|
|
249
360
|
* └──────────────────────────┴─────┘
|
|
250
361
|
*/
|
|
251
|
-
millisecond(): any;
|
|
362
|
+
millisecond(timeZone?: string): any;
|
|
252
363
|
/**
|
|
253
364
|
* Extracts the minute component (0-59) from a Datetime column.
|
|
254
365
|
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
255
366
|
* @returns ColumnExpression
|
|
256
367
|
* @example
|
|
257
|
-
|
|
258
|
-
|
|
368
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
369
|
+
* >>> df
|
|
370
|
+
* shape: (1, 1)
|
|
371
|
+
* ┌──────────────────────────┐
|
|
372
|
+
* │ date │
|
|
373
|
+
* ├──────────────────────────┤
|
|
374
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
375
|
+
* └──────────────────────────┘
|
|
376
|
+
* >>> df.withColumns($df.col("ts").dt.minute().alias("min"))
|
|
259
377
|
* shape: (1, 2)
|
|
260
|
-
*
|
|
261
|
-
* │ ts
|
|
262
|
-
*
|
|
263
|
-
* │ 2026-05-20T10:
|
|
264
|
-
*
|
|
378
|
+
* ┌──────────────────────────┬─────┐
|
|
379
|
+
* │ ts │ min │
|
|
380
|
+
* ├──────────────────────────┼─────┤
|
|
381
|
+
* │ 2026-05-20T10:00:00.123Z │ 0 │
|
|
382
|
+
* └──────────────────────────┴─────┘
|
|
265
383
|
*/
|
|
266
384
|
minute(timeZone?: string): any;
|
|
267
385
|
/**
|
|
@@ -269,8 +387,15 @@ export declare class DateTimeExprNamespace {
|
|
|
269
387
|
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
270
388
|
* @returns ColumnExpression
|
|
271
389
|
* @example
|
|
272
|
-
|
|
273
|
-
|
|
390
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
391
|
+
* >>> df
|
|
392
|
+
* shape: (1, 1)
|
|
393
|
+
* ┌──────────────────────────┐
|
|
394
|
+
* │ date │
|
|
395
|
+
* ├──────────────────────────┤
|
|
396
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
397
|
+
* └──────────────────────────┘
|
|
398
|
+
* >>> df.withColumns($df.col("d").dt.month().alias("m"))
|
|
274
399
|
* shape: (1, 2)
|
|
275
400
|
* ┌────────────┬───┐
|
|
276
401
|
* │ d │ m │
|
|
@@ -283,8 +408,15 @@ export declare class DateTimeExprNamespace {
|
|
|
283
408
|
* Returns a Datetime column shifted to the last calendar day of the month at 00:00:00.000 UTC.
|
|
284
409
|
* @returns ColumnExpression
|
|
285
410
|
* @example
|
|
286
|
-
|
|
287
|
-
|
|
411
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
412
|
+
* >>> df
|
|
413
|
+
* shape: (1, 1)
|
|
414
|
+
* ┌──────────────────────────┐
|
|
415
|
+
* │ date │
|
|
416
|
+
* ├──────────────────────────┤
|
|
417
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
418
|
+
* └──────────────────────────┘
|
|
419
|
+
* >>> df.withColumns($df.col("d").dt.monthEnd().alias("m_end"))
|
|
288
420
|
* shape: (1, 2)
|
|
289
421
|
* ┌────────────┬──────────────────────────┐
|
|
290
422
|
* │ d │ m_end │
|
|
@@ -292,13 +424,20 @@ export declare class DateTimeExprNamespace {
|
|
|
292
424
|
* │ 2026-05-20 │ 2026-05-31T00:00:00.000Z │
|
|
293
425
|
* └────────────┴──────────────────────────┘
|
|
294
426
|
*/
|
|
295
|
-
|
|
427
|
+
monthEnd(): any;
|
|
296
428
|
/**
|
|
297
429
|
* Returns a Datetime column shifted to the first calendar day of the month at 00:00:00.000 UTC.
|
|
298
430
|
* @returns ColumnExpression
|
|
299
431
|
* @example
|
|
300
|
-
|
|
301
|
-
|
|
432
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
433
|
+
* >>> df
|
|
434
|
+
* shape: (1, 1)
|
|
435
|
+
* ┌──────────────────────────┐
|
|
436
|
+
* │ date │
|
|
437
|
+
* ├──────────────────────────┤
|
|
438
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
439
|
+
* └──────────────────────────┘
|
|
440
|
+
* >>> df.withColumns($df.col("d").dt.monthStart().alias("m_start"))
|
|
302
441
|
* shape: (1, 2)
|
|
303
442
|
* ┌────────────┬──────────────────────────┐
|
|
304
443
|
* │ d │ m_start │
|
|
@@ -306,21 +445,29 @@ export declare class DateTimeExprNamespace {
|
|
|
306
445
|
* │ 2026-05-20 │ 2026-05-01T00:00:00.000Z │
|
|
307
446
|
* └────────────┴──────────────────────────┘
|
|
308
447
|
*/
|
|
309
|
-
|
|
448
|
+
monthStart(): any;
|
|
310
449
|
/**
|
|
311
450
|
* Extracts the nanosecond component (0-999,000,000) scaled from Datetime millisecond precision.
|
|
451
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
312
452
|
* @returns ColumnExpression
|
|
313
453
|
* @example
|
|
314
|
-
|
|
315
|
-
|
|
454
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
455
|
+
* >>> df
|
|
456
|
+
* shape: (1, 1)
|
|
457
|
+
* ┌──────────────────────────┐
|
|
458
|
+
* │ date │
|
|
459
|
+
* ├──────────────────────────┤
|
|
460
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
461
|
+
* └──────────────────────────┘
|
|
462
|
+
* >>> df.withColumns($df.col("ts").dt.nanosecond().alias("ns"))
|
|
316
463
|
* shape: (1, 2)
|
|
317
|
-
*
|
|
318
|
-
* │ ts │ ns
|
|
319
|
-
*
|
|
320
|
-
* │ 2026-05-20T10:00:00.
|
|
321
|
-
*
|
|
464
|
+
* ┌──────────────────────────┬───────────┐
|
|
465
|
+
* │ ts │ ns │
|
|
466
|
+
* ├──────────────────────────┼───────────┤
|
|
467
|
+
* │ 2026-05-20T10:00:00.123Z │ 123000000 │
|
|
468
|
+
* └──────────────────────────┴───────────┘
|
|
322
469
|
*/
|
|
323
|
-
nanosecond(): any;
|
|
470
|
+
nanosecond(timeZone?: string): any;
|
|
324
471
|
/**
|
|
325
472
|
* Offsets a Datetime column by N calendar days (numeric constant, column reference, or expression).
|
|
326
473
|
* Reuses $df.duration({ days: n }) and expression addition math under the hood.
|
|
@@ -328,8 +475,15 @@ export declare class DateTimeExprNamespace {
|
|
|
328
475
|
* @param options Day offset configuration options.
|
|
329
476
|
* @returns ColumnExpression
|
|
330
477
|
* @example
|
|
331
|
-
|
|
332
|
-
|
|
478
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
479
|
+
* >>> df
|
|
480
|
+
* shape: (1, 1)
|
|
481
|
+
* ┌──────────────────────────┐
|
|
482
|
+
* │ date │
|
|
483
|
+
* ├──────────────────────────┤
|
|
484
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
485
|
+
* └──────────────────────────┘
|
|
486
|
+
* >>> df.withColumns($df.col("d").dt.offsetDay(5).alias("later"))
|
|
333
487
|
* shape: (1, 2)
|
|
334
488
|
* ┌────────────┬──────────────────────────┐
|
|
335
489
|
* │ d │ later │
|
|
@@ -337,27 +491,43 @@ export declare class DateTimeExprNamespace {
|
|
|
337
491
|
* │ 2026-05-20 │ 2026-05-25T00:00:00.000Z │
|
|
338
492
|
* └────────────┴──────────────────────────┘
|
|
339
493
|
*/
|
|
340
|
-
|
|
494
|
+
offsetDay(n: number | any, options?: DayOffsetOptions): any;
|
|
341
495
|
/**
|
|
342
496
|
* Extracts the day of the year (1-366) from a Datetime column.
|
|
497
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
343
498
|
* @returns ColumnExpression
|
|
344
499
|
* @example
|
|
345
|
-
|
|
346
|
-
|
|
500
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
501
|
+
* >>> df
|
|
502
|
+
* shape: (1, 1)
|
|
503
|
+
* ┌──────────────────────────┐
|
|
504
|
+
* │ date │
|
|
505
|
+
* ├──────────────────────────┤
|
|
506
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
507
|
+
* └──────────────────────────┘
|
|
508
|
+
* >>> df.withColumns($df.col("d").dt.ordinalDay().alias("doy"))
|
|
347
509
|
* shape: (1, 2)
|
|
348
510
|
* ┌────────────┬─────┐
|
|
349
511
|
* │ d │ doy │
|
|
350
512
|
* ├────────────┼─────┤
|
|
351
|
-
* │ 2026-
|
|
513
|
+
* │ 2026-05-20 │ 140 │
|
|
352
514
|
* └────────────┴─────┘
|
|
353
515
|
*/
|
|
354
|
-
|
|
516
|
+
ordinalDay(timeZone?: string): any;
|
|
355
517
|
/**
|
|
356
518
|
* Extracts the calendar quarter of the year (1-4) from a Datetime column.
|
|
519
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to UTC.
|
|
357
520
|
* @returns ColumnExpression
|
|
358
521
|
* @example
|
|
359
|
-
|
|
360
|
-
|
|
522
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
523
|
+
* >>> df
|
|
524
|
+
* shape: (1, 1)
|
|
525
|
+
* ┌──────────────────────────┐
|
|
526
|
+
* │ date │
|
|
527
|
+
* ├──────────────────────────┤
|
|
528
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
529
|
+
* └──────────────────────────┘
|
|
530
|
+
* >>> df.withColumns($df.col("d").dt.quarter().alias("qtr"))
|
|
361
531
|
* shape: (1, 2)
|
|
362
532
|
* ┌────────────┬─────┐
|
|
363
533
|
* │ d │ qtr │
|
|
@@ -365,7 +535,7 @@ export declare class DateTimeExprNamespace {
|
|
|
365
535
|
* │ 2026-05-20 │ 2 │
|
|
366
536
|
* └────────────┴─────┘
|
|
367
537
|
*/
|
|
368
|
-
quarter(): any;
|
|
538
|
+
quarter(timeZone?: string): any;
|
|
369
539
|
/**
|
|
370
540
|
* Replaces specific date and time components (`year`, `month`, `day`, `hour`, `minute`, `second`, `ms`, `timeZone`) of a Datetime column.
|
|
371
541
|
* Unspecified components are preserved from the original value.
|
|
@@ -374,38 +544,61 @@ export declare class DateTimeExprNamespace {
|
|
|
374
544
|
* @param options Object specifying which components to replace.
|
|
375
545
|
* @returns ColumnExpression
|
|
376
546
|
* @example
|
|
377
|
-
|
|
378
|
-
|
|
547
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
548
|
+
* >>> df
|
|
549
|
+
* shape: (1, 1)
|
|
550
|
+
* ┌──────────────────────────┐
|
|
551
|
+
* │ date │
|
|
552
|
+
* ├──────────────────────────┤
|
|
553
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
554
|
+
* └──────────────────────────┘
|
|
555
|
+
* >>> df.withColumns($df.col("ts").dt.replace({ year: 2030, month: 1, day: 1 }).alias("replaced"))
|
|
379
556
|
* shape: (1, 2)
|
|
380
|
-
*
|
|
381
|
-
* │ ts
|
|
382
|
-
*
|
|
383
|
-
* │ 2026-05-
|
|
384
|
-
*
|
|
557
|
+
* ┌──────────────────────────┬──────────────────────────┐
|
|
558
|
+
* │ ts │ replaced │
|
|
559
|
+
* ├──────────────────────────┼──────────────────────────┤
|
|
560
|
+
* │ 2026-05-20T10:00:00.123Z │ 2030-01-01T10:00:00.123Z │
|
|
561
|
+
* └──────────────────────────┴──────────────────────────┘
|
|
385
562
|
*/
|
|
386
563
|
replace(options: ReplaceDateOptions): any;
|
|
387
564
|
/**
|
|
388
565
|
* Extracts the second component (0-59) from a Datetime column.
|
|
389
566
|
* @returns ColumnExpression
|
|
390
567
|
* @example
|
|
391
|
-
|
|
392
|
-
|
|
568
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
569
|
+
* >>> df
|
|
570
|
+
* shape: (1, 1)
|
|
571
|
+
* ┌──────────────────────────┐
|
|
572
|
+
* │ date │
|
|
573
|
+
* ├──────────────────────────┤
|
|
574
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
575
|
+
* └──────────────────────────┘
|
|
576
|
+
* >>> df.withColumns($df.col("ts").dt.second().alias("sec"))
|
|
393
577
|
* shape: (1, 2)
|
|
394
|
-
*
|
|
395
|
-
* │ ts
|
|
396
|
-
*
|
|
397
|
-
* │ 2026-05-20T10:00:
|
|
398
|
-
*
|
|
578
|
+
* ┌──────────────────────────┬─────┐
|
|
579
|
+
* │ ts │ sec │
|
|
580
|
+
* ├──────────────────────────┼─────┤
|
|
581
|
+
* │ 2026-05-20T10:00:00.123Z │ 0 │
|
|
582
|
+
* └──────────────────────────┴─────┘
|
|
399
583
|
*/
|
|
400
584
|
second(): any;
|
|
401
585
|
/**
|
|
402
586
|
* Formats Datetime values into custom formatted strings using strftime directive pattern tokens.
|
|
403
587
|
* Automatically applies the column's assigned timezone unless explicitly overridden in options.
|
|
588
|
+
* @note [Timezone Compatibility]: Timezone-aware formatting relies on native `Intl.DateTimeFormat`
|
|
589
|
+
* timezone resolution. If an invalid or unsupported IANA timezone is provided, formatting safely defaults to `"UTC"`.
|
|
404
590
|
* @param options Formatting pattern string (e.g. `"%Y-%m-%d %H:%M:%S"`) or configuration object.
|
|
405
591
|
* @returns ColumnExpression
|
|
406
592
|
* @example
|
|
407
|
-
|
|
408
|
-
|
|
593
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
594
|
+
* >>> df
|
|
595
|
+
* shape: (1, 1)
|
|
596
|
+
* ┌──────────────────────────┐
|
|
597
|
+
* │ date │
|
|
598
|
+
* ├──────────────────────────┤
|
|
599
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
600
|
+
* └──────────────────────────┘
|
|
601
|
+
* >>> df.withColumns($df.col("d").dt.strftime("%Y/%m/%d").alias("formatted"))
|
|
409
602
|
* shape: (1, 2)
|
|
410
603
|
* ┌────────────┬────────────┐
|
|
411
604
|
* │ d │ formatted │
|
|
@@ -418,14 +611,21 @@ export declare class DateTimeExprNamespace {
|
|
|
418
611
|
* Extracts the time component formatted string (`"HH:MM:SS.mmm"`) from a Datetime column.
|
|
419
612
|
* @returns ColumnExpression
|
|
420
613
|
* @example
|
|
421
|
-
|
|
422
|
-
|
|
614
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
615
|
+
* >>> df
|
|
616
|
+
* shape: (1, 1)
|
|
617
|
+
* ┌──────────────────────────┐
|
|
618
|
+
* │ date │
|
|
619
|
+
* ├──────────────────────────┤
|
|
620
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
621
|
+
* └──────────────────────────┘
|
|
622
|
+
* >>> df.withColumns($df.col("ts").dt.time().alias("time"))
|
|
423
623
|
* shape: (1, 2)
|
|
424
|
-
*
|
|
425
|
-
* │ ts
|
|
426
|
-
*
|
|
427
|
-
* │ 2026-05-20T10:
|
|
428
|
-
*
|
|
624
|
+
* ┌──────────────────────────┬──────────────┐
|
|
625
|
+
* │ ts │ time │
|
|
626
|
+
* ├──────────────────────────┼──────────────┤
|
|
627
|
+
* │ 2026-05-20T10:00:00.123Z │ 10:00:00.123 │
|
|
628
|
+
* └──────────────────────────┴──────────────┘
|
|
429
629
|
*/
|
|
430
630
|
time(): any;
|
|
431
631
|
/**
|
|
@@ -433,114 +633,177 @@ export declare class DateTimeExprNamespace {
|
|
|
433
633
|
* @param unit Time unit resolution.
|
|
434
634
|
* @returns ColumnExpression
|
|
435
635
|
* @example
|
|
436
|
-
|
|
437
|
-
|
|
636
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
637
|
+
* >>> df
|
|
638
|
+
* shape: (1, 1)
|
|
639
|
+
* ┌──────────────────────────┐
|
|
640
|
+
* │ date │
|
|
641
|
+
* ├──────────────────────────┤
|
|
642
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
643
|
+
* └──────────────────────────┘
|
|
644
|
+
* >>> df.withColumns($df.col("d").dt.timestamp("s").alias("ts"))
|
|
438
645
|
* shape: (1, 2)
|
|
439
|
-
*
|
|
440
|
-
* │ d
|
|
441
|
-
*
|
|
442
|
-
* │ 2026-
|
|
443
|
-
*
|
|
646
|
+
* ┌────────────┬────────────┐
|
|
647
|
+
* │ d │ ts │
|
|
648
|
+
* ├────────────┼────────────┤
|
|
649
|
+
* │ 2026-05-20 │ 1779235200 │
|
|
650
|
+
* └────────────┴────────────┘
|
|
444
651
|
*/
|
|
445
652
|
timestamp(unit?: TimeUnit): any;
|
|
446
653
|
/**
|
|
447
654
|
* Converts a Duration value (in milliseconds) to total days count.
|
|
448
655
|
* @returns ColumnExpression
|
|
449
656
|
* @example
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
657
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
658
|
+
* >>> df
|
|
659
|
+
* shape: (1, 1)
|
|
660
|
+
* ┌──────────────────────────┐
|
|
661
|
+
* │ date │
|
|
662
|
+
* ├──────────────────────────┤
|
|
663
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
664
|
+
* └──────────────────────────┘
|
|
665
|
+
* >>> df.withColumns($df.duration({ days: $df.col("add") }).dt.totalDays().alias("days"))
|
|
666
|
+
* shape: (2, 3)
|
|
667
|
+
* ┌────────────┬─────┬──────┐
|
|
668
|
+
* │ dt │ add │ days │
|
|
669
|
+
* ├────────────┼─────┼──────┤
|
|
670
|
+
* │ 2026-01-01 │ 1 │ 1 │
|
|
671
|
+
* │ 2026-01-01 │ 2 │ 2 │
|
|
672
|
+
* └────────────┴─────┴──────┘
|
|
673
|
+
*/
|
|
674
|
+
totalDays(): any;
|
|
460
675
|
/**
|
|
461
676
|
* Converts a Duration value (in milliseconds) to total hours count.
|
|
462
677
|
* @returns ColumnExpression
|
|
463
678
|
* @example
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
679
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
680
|
+
* >>> df
|
|
681
|
+
* shape: (1, 1)
|
|
682
|
+
* ┌──────────────────────────┐
|
|
683
|
+
* │ date │
|
|
684
|
+
* ├──────────────────────────┤
|
|
685
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
686
|
+
* └──────────────────────────┘
|
|
687
|
+
* >>> df.withColumns($df.duration({ days: $df.col("add") }).dt.totalHours().alias("hrs"))
|
|
688
|
+
* shape: (2, 3)
|
|
689
|
+
* ┌────────────┬─────┬─────┐
|
|
690
|
+
* │ dt │ add │ hrs │
|
|
691
|
+
* ├────────────┼─────┼─────┤
|
|
692
|
+
* │ 2026-01-01 │ 1 │ 24 │
|
|
693
|
+
* │ 2026-01-01 │ 2 │ 48 │
|
|
694
|
+
* └────────────┴─────┴─────┘
|
|
695
|
+
*/
|
|
696
|
+
totalHours(): any;
|
|
474
697
|
/**
|
|
475
698
|
* Converts Duration to microsecond count.
|
|
476
699
|
* @returns ColumnExpression
|
|
477
700
|
* @example
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
701
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
702
|
+
* >>> df
|
|
703
|
+
* shape: (1, 1)
|
|
704
|
+
* ┌──────────────────────────┐
|
|
705
|
+
* │ date │
|
|
706
|
+
* ├──────────────────────────┤
|
|
707
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
708
|
+
* └──────────────────────────┘
|
|
709
|
+
* >>> df.withColumns($df.duration({ days: $df.col("add") }).dt.totalMicroseconds().alias("us"))
|
|
710
|
+
* shape: (2, 3)
|
|
711
|
+
* ┌────────────┬─────┬──────────────┐
|
|
712
|
+
* │ dt │ add │ us │
|
|
713
|
+
* ├────────────┼─────┼──────────────┤
|
|
714
|
+
* │ 2026-01-01 │ 1 │ 86400000000 │
|
|
715
|
+
* │ 2026-01-01 │ 2 │ 172800000000 │
|
|
716
|
+
* └────────────┴─────┴──────────────┘
|
|
717
|
+
*/
|
|
718
|
+
totalMicroseconds(): any;
|
|
488
719
|
/**
|
|
489
720
|
* Converts Duration to millisecond count.
|
|
490
721
|
* @returns ColumnExpression
|
|
491
722
|
* @example
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
723
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
724
|
+
* >>> df
|
|
725
|
+
* shape: (1, 1)
|
|
726
|
+
* ┌──────────────────────────┐
|
|
727
|
+
* │ date │
|
|
728
|
+
* ├──────────────────────────┤
|
|
729
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
730
|
+
* └──────────────────────────┘
|
|
731
|
+
* >>> df.withColumns($df.duration({ days: $df.col("add") }).dt.totalMilliseconds().alias("ms"))
|
|
732
|
+
* shape: (2, 3)
|
|
733
|
+
* ┌────────────┬─────┬───────────┐
|
|
734
|
+
* │ dt │ add │ ms │
|
|
735
|
+
* ├────────────┼─────┼───────────┤
|
|
736
|
+
* │ 2026-01-01 │ 1 │ 86400000 │
|
|
737
|
+
* │ 2026-01-01 │ 2 │ 172800000 │
|
|
738
|
+
* └────────────┴─────┴───────────┘
|
|
739
|
+
*/
|
|
740
|
+
totalMilliseconds(): any;
|
|
502
741
|
/**
|
|
503
742
|
* Converts Duration to floating point minutes.
|
|
504
743
|
* @returns ColumnExpression
|
|
505
744
|
* @example
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
745
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
746
|
+
* >>> df
|
|
747
|
+
* shape: (1, 1)
|
|
748
|
+
* ┌──────────────────────────┐
|
|
749
|
+
* │ date │
|
|
750
|
+
* ├──────────────────────────┤
|
|
751
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
752
|
+
* └──────────────────────────┘
|
|
753
|
+
* >>> df.withColumns($df.duration({ days: $df.col("add") }).dt.totalMinutes().alias("mins"))
|
|
754
|
+
* shape: (2, 3)
|
|
755
|
+
* ┌────────────┬─────┬──────┐
|
|
756
|
+
* │ dt │ add │ mins │
|
|
757
|
+
* ├────────────┼─────┼──────┤
|
|
758
|
+
* │ 2026-01-01 │ 1 │ 1440 │
|
|
759
|
+
* │ 2026-01-01 │ 2 │ 2880 │
|
|
760
|
+
* └────────────┴─────┴──────┘
|
|
761
|
+
*/
|
|
762
|
+
totalMinutes(): any;
|
|
516
763
|
/**
|
|
517
764
|
* Converts Duration to nanosecond count.
|
|
518
765
|
* @returns ColumnExpression
|
|
519
766
|
* @example
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
767
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
768
|
+
* >>> df
|
|
769
|
+
* shape: (1, 1)
|
|
770
|
+
* ┌──────────────────────────┐
|
|
771
|
+
* │ date │
|
|
772
|
+
* ├──────────────────────────┤
|
|
773
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
774
|
+
* └──────────────────────────┘
|
|
775
|
+
* >>> df.withColumns($df.duration({ days: $df.col("add") }).dt.totalNanoseconds().alias("ns"))
|
|
776
|
+
* shape: (2, 3)
|
|
777
|
+
* ┌────────────┬─────┬─────────────────┐
|
|
778
|
+
* │ dt │ add │ ns │
|
|
779
|
+
* ├────────────┼─────┼─────────────────┤
|
|
780
|
+
* │ 2026-01-01 │ 1 │ 86400000000000 │
|
|
781
|
+
* │ 2026-01-01 │ 2 │ 172800000000000 │
|
|
782
|
+
* └────────────┴─────┴─────────────────┘
|
|
783
|
+
*/
|
|
784
|
+
totalNanoseconds(): any;
|
|
530
785
|
/**
|
|
531
786
|
* Converts Duration to floating point seconds.
|
|
532
787
|
* @returns ColumnExpression
|
|
533
788
|
* @example
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
789
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
790
|
+
* >>> df
|
|
791
|
+
* shape: (1, 1)
|
|
792
|
+
* ┌──────────────────────────┐
|
|
793
|
+
* │ date │
|
|
794
|
+
* ├──────────────────────────┤
|
|
795
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
796
|
+
* └──────────────────────────┘
|
|
797
|
+
* >>> df.withColumns($df.duration({ days: $df.col("add") }).dt.totalSeconds().alias("secs"))
|
|
798
|
+
* shape: (2, 3)
|
|
799
|
+
* ┌────────────┬─────┬────────┐
|
|
800
|
+
* │ dt │ add │ secs │
|
|
801
|
+
* ├────────────┼─────┼────────┤
|
|
802
|
+
* │ 2026-01-01 │ 1 │ 86400 │
|
|
803
|
+
* │ 2026-01-01 │ 2 │ 172800 │
|
|
804
|
+
* └────────────┴─────┴────────┘
|
|
805
|
+
*/
|
|
806
|
+
totalSeconds(): any;
|
|
544
807
|
/**
|
|
545
808
|
* Returns the UTC offset of a timezone for a given Datetime value.
|
|
546
809
|
* Supports returning the total offset, the standard (base) offset, or just the
|
|
@@ -551,8 +814,15 @@ export declare class DateTimeExprNamespace {
|
|
|
551
814
|
* output unit (`"milliseconds"` | `"minutes"` | `"hours"` | `"iso"` | `"basic"`).
|
|
552
815
|
* @returns ColumnExpression
|
|
553
816
|
* @example
|
|
554
|
-
|
|
555
|
-
|
|
817
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
818
|
+
* >>> df
|
|
819
|
+
* shape: (1, 1)
|
|
820
|
+
* ┌──────────────────────────┐
|
|
821
|
+
* │ date │
|
|
822
|
+
* ├──────────────────────────┤
|
|
823
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
824
|
+
* └──────────────────────────┘
|
|
825
|
+
* >>> df.withColumns($df.col("d").dt.utcOffset("UTC").alias("offset"))
|
|
556
826
|
* shape: (1, 2)
|
|
557
827
|
* ┌────────────┬────────┐
|
|
558
828
|
* │ d │ offset │
|
|
@@ -560,13 +830,21 @@ export declare class DateTimeExprNamespace {
|
|
|
560
830
|
* │ 2026-05-20 │ 0 │
|
|
561
831
|
* └────────────┴────────┘
|
|
562
832
|
*/
|
|
563
|
-
|
|
833
|
+
utcOffset(timeZone?: string, options?: UtcOffsetOptions): any;
|
|
564
834
|
/**
|
|
565
|
-
* Extracts ISO week index. Alias for
|
|
835
|
+
* Extracts ISO week index. Alias for isoWeek.
|
|
836
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
|
|
566
837
|
* @returns ColumnExpression
|
|
567
838
|
* @example
|
|
568
|
-
|
|
569
|
-
|
|
839
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
840
|
+
* >>> df
|
|
841
|
+
* shape: (1, 1)
|
|
842
|
+
* ┌──────────────────────────┐
|
|
843
|
+
* │ date │
|
|
844
|
+
* ├──────────────────────────┤
|
|
845
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
846
|
+
* └──────────────────────────┘
|
|
847
|
+
* >>> df.withColumns($df.col("d").dt.week().alias("week"))
|
|
570
848
|
* shape: (1, 2)
|
|
571
849
|
* ┌────────────┬──────┐
|
|
572
850
|
* │ d │ week │
|
|
@@ -574,19 +852,26 @@ export declare class DateTimeExprNamespace {
|
|
|
574
852
|
* │ 2026-05-20 │ 21 │
|
|
575
853
|
* └────────────┴──────┘
|
|
576
854
|
*/
|
|
577
|
-
week(): any;
|
|
855
|
+
week(timeZone?: string): any;
|
|
578
856
|
/**
|
|
579
857
|
* Extracts weekday component (1=Monday, 7=Sunday).
|
|
580
858
|
* @param timeZone Optional IANA timezone identifier. Defaults to UTC.
|
|
581
859
|
* @returns ColumnExpression
|
|
582
860
|
* @example
|
|
583
|
-
|
|
584
|
-
|
|
861
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
862
|
+
* >>> df
|
|
863
|
+
* shape: (1, 1)
|
|
864
|
+
* ┌──────────────────────────┐
|
|
865
|
+
* │ date │
|
|
866
|
+
* ├──────────────────────────┤
|
|
867
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
868
|
+
* └──────────────────────────┘
|
|
869
|
+
* >>> df.withColumns($df.col("d").dt.weekday().alias("wd"))
|
|
585
870
|
* shape: (1, 2)
|
|
586
871
|
* ┌────────────┬────┐
|
|
587
872
|
* │ d │ wd │
|
|
588
873
|
* ├────────────┼────┤
|
|
589
|
-
* │ 2026-05-
|
|
874
|
+
* │ 2026-05-20 │ 3 │
|
|
590
875
|
* └────────────┴────┘
|
|
591
876
|
*/
|
|
592
877
|
weekday(timeZone?: string): any;
|
|
@@ -595,8 +880,15 @@ export declare class DateTimeExprNamespace {
|
|
|
595
880
|
* @param timeZone Optional IANA timezone identifier. Defaults to UTC.
|
|
596
881
|
* @returns ColumnExpression
|
|
597
882
|
* @example
|
|
598
|
-
|
|
599
|
-
|
|
883
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
884
|
+
* >>> df
|
|
885
|
+
* shape: (1, 1)
|
|
886
|
+
* ┌──────────────────────────┐
|
|
887
|
+
* │ date │
|
|
888
|
+
* ├──────────────────────────┤
|
|
889
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
890
|
+
* └──────────────────────────┘
|
|
891
|
+
* >>> df.withColumns($df.col("d").dt.year().alias("yr"))
|
|
600
892
|
* shape: (1, 2)
|
|
601
893
|
* ┌────────────┬──────┐
|
|
602
894
|
* │ d │ yr │
|
|
@@ -614,7 +906,21 @@ export declare class TemporalExpr extends ExprBase {
|
|
|
614
906
|
* @syntax $df.col(<column_name>).dt
|
|
615
907
|
* @returns DateTimeExprNamespace
|
|
616
908
|
* @example
|
|
909
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
910
|
+
* >>> df
|
|
911
|
+
* shape: (1, 1)
|
|
912
|
+
* ┌──────────────────────────┐
|
|
913
|
+
* │ date │
|
|
914
|
+
* ├──────────────────────────┤
|
|
915
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
916
|
+
* └──────────────────────────┘
|
|
617
917
|
* >>> df.select($df.col("date").dt.year())
|
|
918
|
+
* shape: (1, 1)
|
|
919
|
+
* ┌──────┐
|
|
920
|
+
* │ year │
|
|
921
|
+
* ├──────┤
|
|
922
|
+
* │ 2026 │
|
|
923
|
+
* └──────┘
|
|
618
924
|
*/
|
|
619
925
|
get dt(): DateTimeExprNamespace;
|
|
620
926
|
}
|