df-script 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +3 -1
  2. package/dist/api.d.ts +3 -1
  3. package/dist/assets/index-DBhGK6Tp.css +1 -0
  4. package/dist/assets/index-DEJEV_tU.js +195 -0
  5. package/dist/columnExpressions/ColumnExpr.d.ts +12 -5
  6. package/dist/columnExpressions/ExprBase.d.ts +27 -12
  7. package/dist/columnExpressions/constants.d.ts +2 -0
  8. package/dist/columnExpressions/functions/all.d.ts +23 -0
  9. package/dist/columnExpressions/functions/coalesce.d.ts +29 -0
  10. package/dist/columnExpressions/functions/duration.d.ts +33 -0
  11. package/dist/columnExpressions/functions/element.d.ts +25 -0
  12. package/dist/columnExpressions/functions/exclude.d.ts +24 -0
  13. package/dist/columnExpressions/functions/implode.d.ts +28 -0
  14. package/dist/columnExpressions/functions/lit.d.ts +27 -0
  15. package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
  16. package/dist/columnExpressions/functions/struct.d.ts +31 -0
  17. package/dist/columnExpressions/functions/when.d.ts +36 -6
  18. package/dist/columnExpressions/index.d.ts +2 -0
  19. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +334 -0
  20. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +609 -0
  21. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +533 -5
  22. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
  23. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
  24. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
  25. package/dist/columnExpressions/mixins/StringExpr.d.ts +656 -3
  26. package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
  27. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +588 -11
  28. package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
  29. package/dist/columnExpressions/types.d.ts +1 -0
  30. package/dist/columnExpressions/utils.d.ts +10 -0
  31. package/dist/constants.d.ts +15 -3
  32. package/dist/dataframe/dataframe.d.ts +1073 -3
  33. package/dist/dataframe/grouped/grouped.d.ts +41 -6
  34. package/dist/dataframe/types.d.ts +26 -3
  35. package/dist/dataframe/utils.d.ts +22 -1
  36. package/dist/datatypes/types.d.ts +51 -1
  37. package/dist/exceptions/index.d.ts +33 -0
  38. package/dist/exceptions/utils.d.ts +2 -0
  39. package/dist/functions/concat.d.ts +50 -0
  40. package/dist/functions/read_csv.d.ts +9 -0
  41. package/dist/functions/read_json.d.ts +7 -2
  42. package/dist/index.html +17 -0
  43. package/dist/index.js +6 -6
  44. package/dist/index.mjs +6 -0
  45. package/dist/types.d.ts +70 -14
  46. package/dist/utils/array.d.ts +55 -1
  47. package/dist/utils/csv.d.ts +1 -0
  48. package/dist/utils/date.d.ts +14 -27
  49. package/dist/utils/duration.d.ts +5 -0
  50. package/dist/utils/index.d.ts +1 -0
  51. package/dist/utils/json.d.ts +1 -0
  52. package/dist/utils/number.d.ts +1 -0
  53. package/dist/utils/object.d.ts +1 -0
  54. package/dist/utils/string.d.ts +12 -0
  55. package/package.json +28 -4
  56. package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
  57. package/dist/utils/guards.d.ts +0 -13
  58. package/dist/utils/list.d.ts +0 -217
@@ -1,43 +1,620 @@
1
- import type { TimeUnit } from "../../types";
1
+ import type { TimeUnit, DatetimeTimeUnit, StrftimeOptions, IsBusinessDayOptions, DayOffsetOptions, UtcOffsetOptions, ReplaceDateOptions } 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
+ *
8
+ * **Implementation Notes**
9
+ *
10
+ * _TimeUnit_: `Date` objects are always millisecond-based, so `timeUnit` is schema
11
+ * metadata only. Sub-millisecond precision (`us`, `ns`) cannot be stored; methods such
12
+ * as `microsecond()` and `nanosecond()` always scale from milliseconds. Migrating to
13
+ * raw `BigInt` arrays would be required for true sub-ms storage.
14
+ *
15
+ * _Timezone enforcement_: `convert_time_zone` can only validate that the column is
16
+ * timezone-aware when `_castType` is explicitly set within the expression chain
17
+ * (e.g. after `cast_time_unit`). Enforcement against a column whose type is unknown
18
+ * at expression-build time requires schema-level checks in DataFrame operations.
19
+ */
3
20
  export declare class DateTimeExprNamespace {
4
21
  expr: any;
5
22
  constructor(expr: any);
23
+ /** Returns the column's schema timezone from a prior convert_time_zone call, or null. */
24
+ _colTz(): string | null;
25
+ /** Returns the column's schema time unit from a prior cast_time_unit call, or null. */
26
+ _colTu(): DatetimeTimeUnit | null;
6
27
  _deriveDate(fn: (d: Date) => any): any;
7
- _deriveDuration(fn: (v: number) => number): any;
28
+ /**
29
+ * Casts the schema time unit of a Datetime column (`"ms"`, `"us"`, `"ns"`).
30
+ * This is a metadata-only operation — underlying millisecond Date timestamps are preserved.
31
+ * @param unit Target time unit: `"ms"` (milliseconds), `"us"` (microseconds), or `"ns"` (nanoseconds).
32
+ * @returns ColumnExpression
33
+ * @example
34
+ * >>> const df = $df.data({ ts: ["2026-05-20T10:00:00.123Z"] })
35
+ * >>> df.with_columns($df.col("ts").dt.cast_time_unit("us").alias("ts_us"))
36
+ * shape: (1, 2)
37
+ * ┌──────────────────────────┬──────────────────────────┐
38
+ * │ ts │ ts_us │
39
+ * ├──────────────────────────┼──────────────────────────┤
40
+ * │ 2026-05-20T10:00:00.123Z │ 2026-05-20T10:00:00.123Z │
41
+ * └──────────────────────────┴──────────────────────────┘
42
+ */
43
+ cast_time_unit(unit: DatetimeTimeUnit): any;
44
+ /**
45
+ * Extracts the 1-indexed century component (e.g. 21 for 2026) from a Datetime column.
46
+ * @returns ColumnExpression
47
+ * @example
48
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
49
+ * >>> df.with_columns($df.col("d").dt.century().alias("century"))
50
+ * shape: (1, 2)
51
+ * ┌────────────┬─────────┐
52
+ * │ d │ century │
53
+ * ├────────────┼─────────┤
54
+ * │ 2026-05-20 │ 21 │
55
+ * └────────────┴─────────┘
56
+ */
8
57
  century(): any;
58
+ /**
59
+ * Converts a Datetime column to a different IANA timezone.
60
+ * Preserves the exact UTC epoch instant while changing the timezone label, affecting
61
+ * how local wall-clock component extractors (`hour()`, `day()`, etc.) and `strftime` interpret values.
62
+ * Requires the column to already be timezone-aware; use `replace({ timeZone })`
63
+ * to assign a timezone to a naive column first.
64
+ * @param timeZone Target IANA timezone identifier (e.g. `"UTC"`, `"America/New_York"`, `"Europe/London"`).
65
+ * @returns ColumnExpression
66
+ * @example
67
+ * >>> const df = $df.data({ ts: ["2026-06-01T00:00:00.000Z"] })
68
+ * >>> df.with_columns($df.col("ts").dt.convert_time_zone("America/New_York").alias("ts_ny"))
69
+ * shape: (1, 2)
70
+ * ┌──────────────────────────┬───────────────────────────────┐
71
+ * │ ts │ ts_ny │
72
+ * ├──────────────────────────┼───────────────────────────────┤
73
+ * │ 2026-06-01T00:00:00.000Z │ 2026-05-31 20:00:00.000 EDT │
74
+ * └──────────────────────────┴───────────────────────────────┘
75
+ */
76
+ convert_time_zone(timeZone: string): any;
77
+ /**
78
+ * Extracts the Date object component from a Datetime column, truncating time to 00:00:00.000 UTC.
79
+ * @returns ColumnExpression
80
+ * @example
81
+ * >>> const df = $df.data({ ts: ["2026-05-20T10:30:00Z"] })
82
+ * >>> df.with_columns($df.col("ts").dt.date().alias("date_only"))
83
+ * shape: (1, 2)
84
+ * ┌──────────────────────┬──────────────────────────┐
85
+ * │ ts │ date_only │
86
+ * ├──────────────────────┼──────────────────────────┤
87
+ * │ 2026-05-20T10:30:00Z │ 2026-05-20T00:00:00.000Z │
88
+ * └──────────────────────┴──────────────────────────┘
89
+ */
9
90
  date(): any;
10
- datetime(): any;
11
- day(): any;
91
+ /**
92
+ * Extracts the calendar day component (1-31) from a Datetime column.
93
+ * @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
94
+ * @returns ColumnExpression
95
+ * @example
96
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
97
+ * >>> df.with_columns($df.col("d").dt.day().alias("day"))
98
+ * shape: (1, 2)
99
+ * ┌────────────┬─────┐
100
+ * │ d │ day │
101
+ * ├────────────┼─────┤
102
+ * │ 2026-05-20 │ 20 │
103
+ * └────────────┴─────┘
104
+ */
105
+ day(timeZone?: string): any;
106
+ /**
107
+ * Extracts the total number of days in the month (28-31) for each Datetime value.
108
+ * @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
109
+ * @returns ColumnExpression
110
+ * @example
111
+ * >>> const df = $df.data({ d: ["2024-02-15"] })
112
+ * >>> df.with_columns($df.col("d").dt.days_in_month().alias("dim"))
113
+ * shape: (1, 2)
114
+ * ┌────────────┬─────┐
115
+ * │ d │ dim │
116
+ * ├────────────┼─────┤
117
+ * │ 2024-02-15 │ 29 │
118
+ * └────────────┴─────┘
119
+ */
120
+ days_in_month(timeZone?: string): any;
121
+ /**
122
+ * Returns the epoch duration timestamp offset in the specified time resolution unit.
123
+ * @param unit Time resolution unit (`"ms"`, `"us"`, `"ns"`, `"s"`). Defaults to `"ms"`.
124
+ * @returns ColumnExpression
125
+ * @example
126
+ * >>> const df = $df.data({ d: ["2026-01-01T00:00:00Z"] })
127
+ * >>> df.with_columns($df.col("d").dt.epoch("s").alias("epoch_s"))
128
+ * shape: (1, 2)
129
+ * ┌──────────────────────┬────────────┐
130
+ * │ d │ epoch_s │
131
+ * ├──────────────────────┼────────────┤
132
+ * │ 2026-01-01T00:00:00Z │ 1767225600 │
133
+ * └──────────────────────┴────────────┘
134
+ */
12
135
  epoch(unit?: TimeUnit): any;
13
- hour(): any;
136
+ /**
137
+ * Extracts the local hour component (0-23) from a Datetime column.
138
+ * @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
139
+ * @returns ColumnExpression
140
+ * @example
141
+ * >>> const df = $df.data({ ts: ["2026-05-20T14:30:00Z"] })
142
+ * >>> df.with_columns($df.col("ts").dt.hour().alias("hr"))
143
+ * shape: (1, 2)
144
+ * ┌──────────────────────┬────┐
145
+ * │ ts │ hr │
146
+ * ├──────────────────────┼────┤
147
+ * │ 2026-05-20T14:30:00Z │ 14 │
148
+ * └──────────────────────┴────┘
149
+ */
150
+ hour(timeZone?: string): any;
151
+ /**
152
+ * Evaluates whether each Datetime value falls on a business day.
153
+ * Supports custom weekend day definitions and holiday arrays or timestamp sets.
154
+ * @param options Business day rules and custom holiday configuration options.
155
+ * @returns ColumnExpression
156
+ * @example
157
+ * >>> const df = $df.data({ d: ["2026-05-18"] })
158
+ * >>> df.with_columns($df.col("d").dt.is_business_day().alias("is_bday"))
159
+ * shape: (1, 2)
160
+ * ┌────────────┬─────────┐
161
+ * │ d │ is_bday │
162
+ * ├────────────┼─────────┤
163
+ * │ 2026-05-18 │ true │
164
+ * └────────────┴─────────┘
165
+ */
166
+ is_business_day(options?: IsBusinessDayOptions): any;
167
+ /**
168
+ * Checks if the calendar year of a Datetime value is a leap year (366 days).
169
+ * @returns ColumnExpression
170
+ * @example
171
+ * >>> const df = $df.data({ d: ["2024-01-01", "2026-01-01"] })
172
+ * >>> df.with_columns($df.col("d").dt.is_leap_year().alias("leap"))
173
+ * shape: (2, 2)
174
+ * ┌────────────┬───────┐
175
+ * │ d │ leap │
176
+ * ├────────────┼───────┤
177
+ * │ 2024-01-01 │ true │
178
+ * │ 2026-01-01 │ false │
179
+ * └────────────┴───────┘
180
+ */
14
181
  is_leap_year(): any;
182
+ /**
183
+ * Extracts the ISO 8601 week number (1-53) from a Datetime column.
184
+ * @returns ColumnExpression
185
+ * @example
186
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
187
+ * >>> df.with_columns($df.col("d").dt.iso_week().alias("week"))
188
+ * shape: (1, 2)
189
+ * ┌────────────┬──────┐
190
+ * │ d │ week │
191
+ * ├────────────┼──────┤
192
+ * │ 2026-05-20 │ 21 │
193
+ * └────────────┴──────┘
194
+ */
195
+ iso_week(): any;
196
+ /**
197
+ * Extracts the ISO 8601 week-numbering year from a Datetime column.
198
+ * @returns ColumnExpression
199
+ * @example
200
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
201
+ * >>> df.with_columns($df.col("d").dt.iso_year().alias("iso_yr"))
202
+ * shape: (1, 2)
203
+ * ┌────────────┬────────┐
204
+ * │ d │ iso_yr │
205
+ * ├────────────┼────────┤
206
+ * │ 2026-05-20 │ 2026 │
207
+ * └────────────┴────────┘
208
+ */
209
+ iso_year(): any;
210
+ /**
211
+ * Extracts the microsecond component (0-999,000) scaled from Datetime millisecond precision.
212
+ * @returns ColumnExpression
213
+ * @example
214
+ * >>> const df = $df.data({ ts: ["2026-05-20T10:00:00.123Z"] })
215
+ * >>> df.with_columns($df.col("ts").dt.microsecond().alias("us"))
216
+ * shape: (1, 2)
217
+ * ┌──────────────────────────┬────────┐
218
+ * │ ts │ us │
219
+ * ├──────────────────────────┼────────┤
220
+ * │ 2026-05-20T10:00:00.123Z │ 123000 │
221
+ * └──────────────────────────┴────────┘
222
+ */
15
223
  microsecond(): any;
224
+ /**
225
+ * Extracts the 1-indexed millennium component index (e.g. 3 for the year 2026) from a Datetime column.
226
+ * @returns ColumnExpression
227
+ * @example
228
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
229
+ * >>> df.with_columns($df.col("d").dt.millennium().alias("mil"))
230
+ * shape: (1, 2)
231
+ * ┌────────────┬─────┐
232
+ * │ d │ mil │
233
+ * ├────────────┼─────┤
234
+ * │ 2026-05-20 │ 3 │
235
+ * └────────────┴─────┘
236
+ */
16
237
  millennium(): any;
238
+ /**
239
+ * Extracts the millisecond component (0-999) from a Datetime column.
240
+ * @returns ColumnExpression
241
+ * @example
242
+ * >>> const df = $df.data({ ts: ["2026-05-20T10:00:00.456Z"] })
243
+ * >>> df.with_columns($df.col("ts").dt.millisecond().alias("ms"))
244
+ * shape: (1, 2)
245
+ * ┌──────────────────────────┬─────┐
246
+ * │ ts │ ms │
247
+ * ├──────────────────────────┼─────┤
248
+ * │ 2026-05-20T10:00:00.456Z │ 456 │
249
+ * └──────────────────────────┴─────┘
250
+ */
17
251
  millisecond(): any;
18
- minute(): any;
19
- month(): any;
252
+ /**
253
+ * Extracts the minute component (0-59) from a Datetime column.
254
+ * @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
255
+ * @returns ColumnExpression
256
+ * @example
257
+ * >>> const df = $df.data({ ts: ["2026-05-20T10:45:00Z"] })
258
+ * >>> df.with_columns($df.col("ts").dt.minute().alias("min"))
259
+ * shape: (1, 2)
260
+ * ┌──────────────────────┬─────┐
261
+ * │ ts │ min │
262
+ * ├──────────────────────┼─────┤
263
+ * │ 2026-05-20T10:45:00Z │ 45 │
264
+ * └──────────────────────┴─────┘
265
+ */
266
+ minute(timeZone?: string): any;
267
+ /**
268
+ * Extracts the calendar month component (1-12) from a Datetime column.
269
+ * @param timeZone Optional IANA timezone identifier. Defaults to the column timezone or UTC.
270
+ * @returns ColumnExpression
271
+ * @example
272
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
273
+ * >>> df.with_columns($df.col("d").dt.month().alias("m"))
274
+ * shape: (1, 2)
275
+ * ┌────────────┬───┐
276
+ * │ d │ m │
277
+ * ├────────────┼───┤
278
+ * │ 2026-05-20 │ 5 │
279
+ * └────────────┴───┘
280
+ */
281
+ month(timeZone?: string): any;
282
+ /**
283
+ * Returns a Datetime column shifted to the last calendar day of the month at 00:00:00.000 UTC.
284
+ * @returns ColumnExpression
285
+ * @example
286
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
287
+ * >>> df.with_columns($df.col("d").dt.month_end().alias("m_end"))
288
+ * shape: (1, 2)
289
+ * ┌────────────┬──────────────────────────┐
290
+ * │ d │ m_end │
291
+ * ├────────────┼──────────────────────────┤
292
+ * │ 2026-05-20 │ 2026-05-31T00:00:00.000Z │
293
+ * └────────────┴──────────────────────────┘
294
+ */
20
295
  month_end(): any;
296
+ /**
297
+ * Returns a Datetime column shifted to the first calendar day of the month at 00:00:00.000 UTC.
298
+ * @returns ColumnExpression
299
+ * @example
300
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
301
+ * >>> df.with_columns($df.col("d").dt.month_start().alias("m_start"))
302
+ * shape: (1, 2)
303
+ * ┌────────────┬──────────────────────────┐
304
+ * │ d │ m_start │
305
+ * ├────────────┼──────────────────────────┤
306
+ * │ 2026-05-20 │ 2026-05-01T00:00:00.000Z │
307
+ * └────────────┴──────────────────────────┘
308
+ */
21
309
  month_start(): any;
310
+ /**
311
+ * Extracts the nanosecond component (0-999,000,000) scaled from Datetime millisecond precision.
312
+ * @returns ColumnExpression
313
+ * @example
314
+ * >>> const df = $df.data({ ts: ["2026-05-20T10:00:00.001Z"] })
315
+ * >>> df.with_columns($df.col("ts").dt.nanosecond().alias("ns"))
316
+ * shape: (1, 2)
317
+ * ┌──────────────────────────┬─────────┐
318
+ * │ ts │ ns │
319
+ * ├──────────────────────────┼─────────┤
320
+ * │ 2026-05-20T10:00:00.001Z │ 1000000 │
321
+ * └──────────────────────────┴─────────┘
322
+ */
22
323
  nanosecond(): any;
324
+ /**
325
+ * Offsets a Datetime column by N calendar days (numeric constant, column reference, or expression).
326
+ * Reuses $df.duration({ days: n }) and expression addition math under the hood.
327
+ * @param n Number of calendar days to offset (positive or negative).
328
+ * @param options Day offset configuration options.
329
+ * @returns ColumnExpression
330
+ * @example
331
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
332
+ * >>> df.with_columns($df.col("d").dt.offset_day(5).alias("later"))
333
+ * shape: (1, 2)
334
+ * ┌────────────┬──────────────────────────┐
335
+ * │ d │ later │
336
+ * ├────────────┼──────────────────────────┤
337
+ * │ 2026-05-20 │ 2026-05-25T00:00:00.000Z │
338
+ * └────────────┴──────────────────────────┘
339
+ */
340
+ offset_day(n: number | any, options?: DayOffsetOptions): any;
341
+ /**
342
+ * Extracts the day of the year (1-366) from a Datetime column.
343
+ * @returns ColumnExpression
344
+ * @example
345
+ * >>> const df = $df.data({ d: ["2026-02-01"] })
346
+ * >>> df.with_columns($df.col("d").dt.ordinal_day().alias("doy"))
347
+ * shape: (1, 2)
348
+ * ┌────────────┬─────┐
349
+ * │ d │ doy │
350
+ * ├────────────┼─────┤
351
+ * │ 2026-02-01 │ 32 │
352
+ * └────────────┴─────┘
353
+ */
23
354
  ordinal_day(): any;
355
+ /**
356
+ * Extracts the calendar quarter of the year (1-4) from a Datetime column.
357
+ * @returns ColumnExpression
358
+ * @example
359
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
360
+ * >>> df.with_columns($df.col("d").dt.quarter().alias("qtr"))
361
+ * shape: (1, 2)
362
+ * ┌────────────┬─────┐
363
+ * │ d │ qtr │
364
+ * ├────────────┼─────┤
365
+ * │ 2026-05-20 │ 2 │
366
+ * └────────────┴─────┘
367
+ */
24
368
  quarter(): any;
369
+ /**
370
+ * Replaces specific date and time components (`year`, `month`, `day`, `hour`, `minute`, `second`, `ms`, `timeZone`) of a Datetime column.
371
+ * Unspecified components are preserved from the original value.
372
+ * When `timeZone` is provided in options, components are interpreted in that timezone.
373
+ * Note: `month` is 1-indexed (1 = January, 12 = December); `day` is 1-indexed (1-31).
374
+ * @param options Object specifying which components to replace.
375
+ * @returns ColumnExpression
376
+ * @example
377
+ * >>> const df = $df.data({ ts: ["2026-05-20T14:30:00Z"] })
378
+ * >>> df.with_columns($df.col("ts").dt.replace({ year: 2030, month: 1, day: 1 }).alias("replaced"))
379
+ * shape: (1, 2)
380
+ * ┌──────────────────────┬──────────────────────────┐
381
+ * │ ts │ replaced │
382
+ * ├──────────────────────┼──────────────────────────┤
383
+ * │ 2026-05-20T14:30:00Z │ 2030-01-01T14:30:00.000Z │
384
+ * └──────────────────────┴──────────────────────────┘
385
+ */
386
+ replace(options: ReplaceDateOptions): any;
387
+ /**
388
+ * Extracts the second component (0-59) from a Datetime column.
389
+ * @returns ColumnExpression
390
+ * @example
391
+ * >>> const df = $df.data({ ts: ["2026-05-20T10:00:45Z"] })
392
+ * >>> df.with_columns($df.col("ts").dt.second().alias("sec"))
393
+ * shape: (1, 2)
394
+ * ┌──────────────────────┬─────┐
395
+ * │ ts │ sec │
396
+ * ├──────────────────────┼─────┤
397
+ * │ 2026-05-20T10:00:45Z │ 45 │
398
+ * └──────────────────────┴─────┘
399
+ */
25
400
  second(): any;
26
- strftime(format: string, locale?: string): any;
401
+ /**
402
+ * Formats Datetime values into custom formatted strings using strftime directive pattern tokens.
403
+ * Automatically applies the column's assigned timezone unless explicitly overridden in options.
404
+ * @param options Formatting pattern string (e.g. `"%Y-%m-%d %H:%M:%S"`) or configuration object.
405
+ * @returns ColumnExpression
406
+ * @example
407
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
408
+ * >>> df.with_columns($df.col("d").dt.strftime("%Y/%m/%d").alias("formatted"))
409
+ * shape: (1, 2)
410
+ * ┌────────────┬────────────┐
411
+ * │ d │ formatted │
412
+ * ├────────────┼────────────┤
413
+ * │ 2026-05-20 │ 2026/05/20 │
414
+ * └────────────┴────────────┘
415
+ */
416
+ strftime(options: StrftimeOptions): any;
417
+ /**
418
+ * Extracts the time component formatted string (`"HH:MM:SS.mmm"`) from a Datetime column.
419
+ * @returns ColumnExpression
420
+ * @example
421
+ * >>> const df = $df.data({ ts: ["2026-05-20T10:30:00Z"] })
422
+ * >>> df.with_columns($df.col("ts").dt.time().alias("time"))
423
+ * shape: (1, 2)
424
+ * ┌──────────────────────┬──────────────┐
425
+ * │ ts │ time │
426
+ * ├──────────────────────┼──────────────┤
427
+ * │ 2026-05-20T10:30:00Z │ 10:30:00.000 │
428
+ * └──────────────────────┴──────────────┘
429
+ */
27
430
  time(): any;
431
+ /**
432
+ * Returns numeric timestamp relative to Epoch. Alias for epoch.
433
+ * @param unit Time unit resolution.
434
+ * @returns ColumnExpression
435
+ * @example
436
+ * >>> const df = $df.data({ d: ["2026-01-01T00:00:00Z"] })
437
+ * >>> df.with_columns($df.col("d").dt.timestamp("s").alias("ts"))
438
+ * shape: (1, 2)
439
+ * ┌──────────────────────┬────────────┐
440
+ * │ d │ ts │
441
+ * ├──────────────────────┼────────────┤
442
+ * │ 2026-01-01T00:00:00Z │ 1767225600 │
443
+ * └──────────────────────┴────────────┘
444
+ */
28
445
  timestamp(unit?: TimeUnit): any;
29
- to_string(format: string, locale?: string): any;
446
+ /**
447
+ * Converts a Duration value (in milliseconds) to total days count.
448
+ * @returns ColumnExpression
449
+ * @example
450
+ * >>> const df = $df.data({ dur: [86400000] })
451
+ * >>> df.with_columns($df.col("dur").dt.total_days().alias("days"))
452
+ * shape: (1, 2)
453
+ * ┌──────────┬──────┐
454
+ * │ dur │ days │
455
+ * ├──────────┼──────┤
456
+ * │ 86400000 │ 1 │
457
+ * └──────────┴──────┘
458
+ */
30
459
  total_days(): any;
460
+ /**
461
+ * Converts a Duration value (in milliseconds) to total hours count.
462
+ * @returns ColumnExpression
463
+ * @example
464
+ * >>> const df = $df.data({ dur: [3600000] })
465
+ * >>> df.with_columns($df.col("dur").dt.total_hours().alias("hrs"))
466
+ * shape: (1, 2)
467
+ * ┌─────────┬─────┐
468
+ * │ dur │ hrs │
469
+ * ├─────────┼─────┤
470
+ * │ 3600000 │ 1 │
471
+ * └─────────┴─────┘
472
+ */
31
473
  total_hours(): any;
474
+ /**
475
+ * Converts Duration to microsecond count.
476
+ * @returns ColumnExpression
477
+ * @example
478
+ * >>> const df = $df.data({ dur: [10] })
479
+ * >>> df.with_columns($df.col("dur").dt.total_microseconds().alias("us"))
480
+ * shape: (1, 2)
481
+ * ┌─────┬───────┐
482
+ * │ dur │ us │
483
+ * ├─────┼───────┤
484
+ * │ 10 │ 10000 │
485
+ * └─────┴───────┘
486
+ */
32
487
  total_microseconds(): any;
488
+ /**
489
+ * Converts Duration to millisecond count.
490
+ * @returns ColumnExpression
491
+ * @example
492
+ * >>> const df = $df.data({ dur: [500] })
493
+ * >>> df.with_columns($df.col("dur").dt.total_milliseconds().alias("ms"))
494
+ * shape: (1, 2)
495
+ * ┌─────┬─────┐
496
+ * │ dur │ ms │
497
+ * ├─────┼─────┤
498
+ * │ 500 │ 500 │
499
+ * └─────┴─────┘
500
+ */
33
501
  total_milliseconds(): any;
502
+ /**
503
+ * Converts Duration to floating point minutes.
504
+ * @returns ColumnExpression
505
+ * @example
506
+ * >>> const df = $df.data({ dur: [60000] })
507
+ * >>> df.with_columns($df.col("dur").dt.total_minutes().alias("mins"))
508
+ * shape: (1, 2)
509
+ * ┌───────┬──────┐
510
+ * │ dur │ mins │
511
+ * ├───────┼──────┤
512
+ * │ 60000 │ 1 │
513
+ * └───────┴──────┘
514
+ */
34
515
  total_minutes(): any;
516
+ /**
517
+ * Converts Duration to nanosecond count.
518
+ * @returns ColumnExpression
519
+ * @example
520
+ * >>> const df = $df.data({ dur: [1] })
521
+ * >>> df.with_columns($df.col("dur").dt.total_nanoseconds().alias("ns"))
522
+ * shape: (1, 2)
523
+ * ┌─────┬─────────┐
524
+ * │ dur │ ns │
525
+ * ├─────┼─────────┤
526
+ * │ 1 │ 1000000 │
527
+ * └─────┴─────────┘
528
+ */
35
529
  total_nanoseconds(): any;
530
+ /**
531
+ * Converts Duration to floating point seconds.
532
+ * @returns ColumnExpression
533
+ * @example
534
+ * >>> const df = $df.data({ dur: [1000] })
535
+ * >>> df.with_columns($df.col("dur").dt.total_seconds().alias("secs"))
536
+ * shape: (1, 2)
537
+ * ┌──────┬──────┐
538
+ * │ dur │ secs │
539
+ * ├──────┼──────┤
540
+ * │ 1000 │ 1 │
541
+ * └──────┴──────┘
542
+ */
36
543
  total_seconds(): any;
544
+ /**
545
+ * Returns the UTC offset of a timezone for a given Datetime value.
546
+ * Supports returning the total offset, the standard (base) offset, or just the
547
+ * daylight saving time component, in multiple output formats.
548
+ * @param timeZone Optional IANA timezone identifier. Defaults to the system local timezone.
549
+ * @param options Output configuration: `type` selects which offset component to return
550
+ * (`"total"` | `"standardTime"` | `"daylightSavingTime"`), and `format` controls the
551
+ * output unit (`"milliseconds"` | `"minutes"` | `"hours"` | `"iso"` | `"basic"`).
552
+ * @returns ColumnExpression
553
+ * @example
554
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
555
+ * >>> df.with_columns($df.col("d").dt.utc_offset("UTC").alias("offset"))
556
+ * shape: (1, 2)
557
+ * ┌────────────┬────────┐
558
+ * │ d │ offset │
559
+ * ├────────────┼────────┤
560
+ * │ 2026-05-20 │ 0 │
561
+ * └────────────┴────────┘
562
+ */
563
+ utc_offset(timeZone?: string, options?: UtcOffsetOptions): any;
564
+ /**
565
+ * Extracts ISO week index. Alias for iso_week.
566
+ * @returns ColumnExpression
567
+ * @example
568
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
569
+ * >>> df.with_columns($df.col("d").dt.week().alias("week"))
570
+ * shape: (1, 2)
571
+ * ┌────────────┬──────┐
572
+ * │ d │ week │
573
+ * ├────────────┼──────┤
574
+ * │ 2026-05-20 │ 21 │
575
+ * └────────────┴──────┘
576
+ */
37
577
  week(): any;
38
- weekday(): any;
39
- year(): any;
578
+ /**
579
+ * Extracts weekday component (1=Monday, 7=Sunday).
580
+ * @param timeZone Optional IANA timezone identifier. Defaults to UTC.
581
+ * @returns ColumnExpression
582
+ * @example
583
+ * >>> const df = $df.data({ d: ["2026-05-18"] })
584
+ * >>> df.with_columns($df.col("d").dt.weekday().alias("wd"))
585
+ * shape: (1, 2)
586
+ * ┌────────────┬────┐
587
+ * │ d │ wd │
588
+ * ├────────────┼────┤
589
+ * │ 2026-05-18 │ 1 │
590
+ * └────────────┴────┘
591
+ */
592
+ weekday(timeZone?: string): any;
593
+ /**
594
+ * Extracts the year component from a Datetime column.
595
+ * @param timeZone Optional IANA timezone identifier. Defaults to UTC.
596
+ * @returns ColumnExpression
597
+ * @example
598
+ * >>> const df = $df.data({ d: ["2026-05-20"] })
599
+ * >>> df.with_columns($df.col("d").dt.year().alias("yr"))
600
+ * shape: (1, 2)
601
+ * ┌────────────┬──────┐
602
+ * │ d │ yr │
603
+ * ├────────────┼──────┤
604
+ * │ 2026-05-20 │ 2026 │
605
+ * └────────────┴──────┘
606
+ */
607
+ year(timeZone?: string): any;
40
608
  }
41
609
  export declare class TemporalExpr extends ExprBase {
610
+ /**
611
+ * Datetime namespace accessor for date, time, and duration operations.
612
+ * @namespace $df.col
613
+ * @category ColumnExpression
614
+ * @syntax $df.col(<column_name>).dt
615
+ * @returns DateTimeExprNamespace
616
+ * @example
617
+ * >>> df.select($df.col("date").dt.year())
618
+ */
42
619
  get dt(): DateTimeExprNamespace;
43
620
  }