df-script 1.7.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.
- package/README.md +2 -0
- package/dist/api.d.ts +2 -1
- package/dist/columnExpressions/ExprBase.d.ts +1 -0
- package/dist/columnExpressions/constants.d.ts +1 -0
- package/dist/columnExpressions/functions/duration.d.ts +33 -0
- package/dist/columnExpressions/index.d.ts +1 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +123 -72
- package/dist/columnExpressions/utils.d.ts +10 -0
- package/dist/constants.d.ts +15 -3
- package/dist/dataframe/dataframe.d.ts +233 -93
- package/dist/dataframe/types.d.ts +25 -3
- package/dist/dataframe/utils.d.ts +21 -1
- package/dist/datatypes/types.d.ts +8 -3
- package/dist/exceptions/index.d.ts +10 -0
- package/dist/exceptions/utils.d.ts +2 -0
- package/dist/index.js +6 -6
- package/dist/index.mjs +6 -6
- package/dist/types.d.ts +24 -1
- package/dist/utils/array.d.ts +23 -0
- package/dist/utils/date.d.ts +6 -2
- package/dist/utils/duration.d.ts +5 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/trentamorris/df-script)
|
|
4
4
|
[](DONATIONS.md)
|
|
5
|
+
[](#)
|
|
6
|
+
[](#)
|
|
5
7
|
|
|
6
8
|
DFScript is a lightweight, high-performance, and **zero-dependency** data analysis library for TypeScript and JavaScript. Heavily inspired by modern dataframe libraries like **Polars** and **Pandas**, DFScript brings a robust, expression-based columnar data processing engine directly to the JavaScript ecosystem.
|
|
7
9
|
|
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataFrame } from "./dataframe";
|
|
2
|
-
import { ColumnExpr, lit, all, exclude, coalesce, when, implode, seq_range, element, struct } from "./columnExpressions";
|
|
2
|
+
import { ColumnExpr, lit, all, exclude, coalesce, when, implode, seq_range, element, struct, duration } from "./columnExpressions";
|
|
3
3
|
import { DataType } from "./datatypes";
|
|
4
4
|
import { concat, read_json, read_csv } from "./functions";
|
|
5
5
|
import type { RowRecord, DataFrameSchema, ColumnDict, InferSchema } from "./types";
|
|
@@ -20,6 +20,7 @@ export declare const $df: {
|
|
|
20
20
|
seq_range: typeof seq_range;
|
|
21
21
|
element: typeof element;
|
|
22
22
|
struct: typeof struct;
|
|
23
|
+
duration: typeof duration;
|
|
23
24
|
DataType: {
|
|
24
25
|
Int8: import("./datatypes").Int8Type;
|
|
25
26
|
Int16: import("./datatypes").Int16Type;
|
|
@@ -11,6 +11,7 @@ export declare class ExprBase implements IExpr {
|
|
|
11
11
|
_isLiteral?: boolean;
|
|
12
12
|
_literalValue?: any;
|
|
13
13
|
_aggFn?: AggFn<any> | null;
|
|
14
|
+
_castType?: RegisteredDataType;
|
|
14
15
|
_groupingOpsIndex?: number;
|
|
15
16
|
_partitionOpsIndex?: number;
|
|
16
17
|
_partitionBy: (string | IExpr)[] | null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ColumnExpr } from "../ColumnExpr";
|
|
2
|
+
import type { IntoExpr, DatetimeTimeUnit } from "../../types";
|
|
3
|
+
export interface DurationOptions {
|
|
4
|
+
weeks?: IntoExpr | number;
|
|
5
|
+
days?: IntoExpr | number;
|
|
6
|
+
hours?: IntoExpr | number;
|
|
7
|
+
minutes?: IntoExpr | number;
|
|
8
|
+
seconds?: IntoExpr | number;
|
|
9
|
+
milliseconds?: IntoExpr | number;
|
|
10
|
+
microseconds?: IntoExpr | number;
|
|
11
|
+
nanoseconds?: IntoExpr | number;
|
|
12
|
+
timeUnit?: DatetimeTimeUnit;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a Duration expression column from numeric values, column references, or expressions.
|
|
16
|
+
*
|
|
17
|
+
* @param {DurationOptions} [options] Duration component options (weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, timeUnit).
|
|
18
|
+
* @returns {ColumnExpr<any>} A column expression with the calculated duration values.
|
|
19
|
+
* @namespace $df
|
|
20
|
+
* @category ColumnExpression
|
|
21
|
+
* @syntax $df.duration(options)
|
|
22
|
+
* @example
|
|
23
|
+
* >>> const df = $df.data({ dt: ["2026-01-01"], add: [1, 2] })
|
|
24
|
+
* >>> df.select($df.col("dt").cast($df.DataType.Datetime).add($df.duration({ days: "add" })).alias("add_days"))
|
|
25
|
+
* shape: (2, 1)
|
|
26
|
+
* ┌──────────────────────────┐
|
|
27
|
+
* │ add_days │
|
|
28
|
+
* ├──────────────────────────┤
|
|
29
|
+
* │ 2026-01-02T00:00:00.000Z │
|
|
30
|
+
* │ 2026-01-03T00:00:00.000Z │
|
|
31
|
+
* └──────────────────────────┘
|
|
32
|
+
*/
|
|
33
|
+
export declare function duration(options?: DurationOptions): ColumnExpr<any>;
|
|
@@ -1,17 +1,48 @@
|
|
|
1
|
-
import type { TimeUnit, StrftimeOptions, IsBusinessDayOptions,
|
|
1
|
+
import type { TimeUnit, DatetimeTimeUnit, StrftimeOptions, IsBusinessDayOptions, DayOffsetOptions, UtcOffsetOptions, ReplaceDateOptions } from "../../types";
|
|
2
2
|
import { ExprBase } from "../ExprBase";
|
|
3
3
|
/**
|
|
4
4
|
* @namespace $df.col.dt
|
|
5
5
|
* @category ColumnExpression
|
|
6
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.
|
|
7
19
|
*/
|
|
8
20
|
export declare class DateTimeExprNamespace {
|
|
9
21
|
expr: any;
|
|
10
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;
|
|
11
27
|
_deriveDate(fn: (d: Date) => any): any;
|
|
12
|
-
_deriveDuration(fn: (v: number) => number): any;
|
|
13
28
|
/**
|
|
14
|
-
*
|
|
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.
|
|
15
46
|
* @returns ColumnExpression
|
|
16
47
|
* @example
|
|
17
48
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -25,7 +56,26 @@ export declare class DateTimeExprNamespace {
|
|
|
25
56
|
*/
|
|
26
57
|
century(): any;
|
|
27
58
|
/**
|
|
28
|
-
*
|
|
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.
|
|
29
79
|
* @returns ColumnExpression
|
|
30
80
|
* @example
|
|
31
81
|
* >>> const df = $df.data({ ts: ["2026-05-20T10:30:00Z"] })
|
|
@@ -40,6 +90,7 @@ export declare class DateTimeExprNamespace {
|
|
|
40
90
|
date(): any;
|
|
41
91
|
/**
|
|
42
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.
|
|
43
94
|
* @returns ColumnExpression
|
|
44
95
|
* @example
|
|
45
96
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -51,9 +102,10 @@ export declare class DateTimeExprNamespace {
|
|
|
51
102
|
* │ 2026-05-20 │ 20 │
|
|
52
103
|
* └────────────┴─────┘
|
|
53
104
|
*/
|
|
54
|
-
day(): any;
|
|
105
|
+
day(timeZone?: string): any;
|
|
55
106
|
/**
|
|
56
|
-
* Extracts number of days in the month.
|
|
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.
|
|
57
109
|
* @returns ColumnExpression
|
|
58
110
|
* @example
|
|
59
111
|
* >>> const df = $df.data({ d: ["2024-02-15"] })
|
|
@@ -65,10 +117,10 @@ export declare class DateTimeExprNamespace {
|
|
|
65
117
|
* │ 2024-02-15 │ 29 │
|
|
66
118
|
* └────────────┴─────┘
|
|
67
119
|
*/
|
|
68
|
-
days_in_month(): any;
|
|
120
|
+
days_in_month(timeZone?: string): any;
|
|
69
121
|
/**
|
|
70
|
-
* Returns epoch duration timestamp offset.
|
|
71
|
-
* @param unit Time resolution unit ("ms"
|
|
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"`.
|
|
72
124
|
* @returns ColumnExpression
|
|
73
125
|
* @example
|
|
74
126
|
* >>> const df = $df.data({ d: ["2026-01-01T00:00:00Z"] })
|
|
@@ -82,7 +134,8 @@ export declare class DateTimeExprNamespace {
|
|
|
82
134
|
*/
|
|
83
135
|
epoch(unit?: TimeUnit): any;
|
|
84
136
|
/**
|
|
85
|
-
* Extracts the hour component (0-23) from a Datetime column.
|
|
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.
|
|
86
139
|
* @returns ColumnExpression
|
|
87
140
|
* @example
|
|
88
141
|
* >>> const df = $df.data({ ts: ["2026-05-20T14:30:00Z"] })
|
|
@@ -94,10 +147,11 @@ export declare class DateTimeExprNamespace {
|
|
|
94
147
|
* │ 2026-05-20T14:30:00Z │ 14 │
|
|
95
148
|
* └──────────────────────┴────┘
|
|
96
149
|
*/
|
|
97
|
-
hour(): any;
|
|
150
|
+
hour(timeZone?: string): any;
|
|
98
151
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
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.
|
|
101
155
|
* @returns ColumnExpression
|
|
102
156
|
* @example
|
|
103
157
|
* >>> const df = $df.data({ d: ["2026-05-18"] })
|
|
@@ -111,7 +165,7 @@ export declare class DateTimeExprNamespace {
|
|
|
111
165
|
*/
|
|
112
166
|
is_business_day(options?: IsBusinessDayOptions): any;
|
|
113
167
|
/**
|
|
114
|
-
* Checks if year is a leap year.
|
|
168
|
+
* Checks if the calendar year of a Datetime value is a leap year (366 days).
|
|
115
169
|
* @returns ColumnExpression
|
|
116
170
|
* @example
|
|
117
171
|
* >>> const df = $df.data({ d: ["2024-01-01", "2026-01-01"] })
|
|
@@ -126,7 +180,7 @@ export declare class DateTimeExprNamespace {
|
|
|
126
180
|
*/
|
|
127
181
|
is_leap_year(): any;
|
|
128
182
|
/**
|
|
129
|
-
* Extracts ISO week
|
|
183
|
+
* Extracts the ISO 8601 week number (1-53) from a Datetime column.
|
|
130
184
|
* @returns ColumnExpression
|
|
131
185
|
* @example
|
|
132
186
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -140,7 +194,7 @@ export declare class DateTimeExprNamespace {
|
|
|
140
194
|
*/
|
|
141
195
|
iso_week(): any;
|
|
142
196
|
/**
|
|
143
|
-
* Extracts ISO
|
|
197
|
+
* Extracts the ISO 8601 week-numbering year from a Datetime column.
|
|
144
198
|
* @returns ColumnExpression
|
|
145
199
|
* @example
|
|
146
200
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -154,7 +208,7 @@ export declare class DateTimeExprNamespace {
|
|
|
154
208
|
*/
|
|
155
209
|
iso_year(): any;
|
|
156
210
|
/**
|
|
157
|
-
* Extracts
|
|
211
|
+
* Extracts the microsecond component (0-999,000) scaled from Datetime millisecond precision.
|
|
158
212
|
* @returns ColumnExpression
|
|
159
213
|
* @example
|
|
160
214
|
* >>> const df = $df.data({ ts: ["2026-05-20T10:00:00.123Z"] })
|
|
@@ -168,7 +222,7 @@ export declare class DateTimeExprNamespace {
|
|
|
168
222
|
*/
|
|
169
223
|
microsecond(): any;
|
|
170
224
|
/**
|
|
171
|
-
* Extracts millennium component index.
|
|
225
|
+
* Extracts the 1-indexed millennium component index (e.g. 3 for the year 2026) from a Datetime column.
|
|
172
226
|
* @returns ColumnExpression
|
|
173
227
|
* @example
|
|
174
228
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -182,7 +236,7 @@ export declare class DateTimeExprNamespace {
|
|
|
182
236
|
*/
|
|
183
237
|
millennium(): any;
|
|
184
238
|
/**
|
|
185
|
-
* Extracts
|
|
239
|
+
* Extracts the millisecond component (0-999) from a Datetime column.
|
|
186
240
|
* @returns ColumnExpression
|
|
187
241
|
* @example
|
|
188
242
|
* >>> const df = $df.data({ ts: ["2026-05-20T10:00:00.456Z"] })
|
|
@@ -197,6 +251,7 @@ export declare class DateTimeExprNamespace {
|
|
|
197
251
|
millisecond(): any;
|
|
198
252
|
/**
|
|
199
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.
|
|
200
255
|
* @returns ColumnExpression
|
|
201
256
|
* @example
|
|
202
257
|
* >>> const df = $df.data({ ts: ["2026-05-20T10:45:00Z"] })
|
|
@@ -208,9 +263,10 @@ export declare class DateTimeExprNamespace {
|
|
|
208
263
|
* │ 2026-05-20T10:45:00Z │ 45 │
|
|
209
264
|
* └──────────────────────┴─────┘
|
|
210
265
|
*/
|
|
211
|
-
minute(): any;
|
|
266
|
+
minute(timeZone?: string): any;
|
|
212
267
|
/**
|
|
213
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.
|
|
214
270
|
* @returns ColumnExpression
|
|
215
271
|
* @example
|
|
216
272
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -222,9 +278,9 @@ export declare class DateTimeExprNamespace {
|
|
|
222
278
|
* │ 2026-05-20 │ 5 │
|
|
223
279
|
* └────────────┴───┘
|
|
224
280
|
*/
|
|
225
|
-
month(): any;
|
|
281
|
+
month(timeZone?: string): any;
|
|
226
282
|
/**
|
|
227
|
-
* Returns
|
|
283
|
+
* Returns a Datetime column shifted to the last calendar day of the month at 00:00:00.000 UTC.
|
|
228
284
|
* @returns ColumnExpression
|
|
229
285
|
* @example
|
|
230
286
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -238,7 +294,7 @@ export declare class DateTimeExprNamespace {
|
|
|
238
294
|
*/
|
|
239
295
|
month_end(): any;
|
|
240
296
|
/**
|
|
241
|
-
* Returns
|
|
297
|
+
* Returns a Datetime column shifted to the first calendar day of the month at 00:00:00.000 UTC.
|
|
242
298
|
* @returns ColumnExpression
|
|
243
299
|
* @example
|
|
244
300
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -252,7 +308,7 @@ export declare class DateTimeExprNamespace {
|
|
|
252
308
|
*/
|
|
253
309
|
month_start(): any;
|
|
254
310
|
/**
|
|
255
|
-
* Extracts
|
|
311
|
+
* Extracts the nanosecond component (0-999,000,000) scaled from Datetime millisecond precision.
|
|
256
312
|
* @returns ColumnExpression
|
|
257
313
|
* @example
|
|
258
314
|
* >>> const df = $df.data({ ts: ["2026-05-20T10:00:00.001Z"] })
|
|
@@ -266,25 +322,10 @@ export declare class DateTimeExprNamespace {
|
|
|
266
322
|
*/
|
|
267
323
|
nanosecond(): any;
|
|
268
324
|
/**
|
|
269
|
-
* Offsets
|
|
270
|
-
*
|
|
271
|
-
* @param
|
|
272
|
-
* @
|
|
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.
|
|
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.
|
|
288
329
|
* @returns ColumnExpression
|
|
289
330
|
* @example
|
|
290
331
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -296,9 +337,9 @@ export declare class DateTimeExprNamespace {
|
|
|
296
337
|
* │ 2026-05-20 │ 2026-05-25T00:00:00.000Z │
|
|
297
338
|
* └────────────┴──────────────────────────┘
|
|
298
339
|
*/
|
|
299
|
-
offset_day(n: number | any, options?:
|
|
340
|
+
offset_day(n: number | any, options?: DayOffsetOptions): any;
|
|
300
341
|
/**
|
|
301
|
-
*
|
|
342
|
+
* Extracts the day of the year (1-366) from a Datetime column.
|
|
302
343
|
* @returns ColumnExpression
|
|
303
344
|
* @example
|
|
304
345
|
* >>> const df = $df.data({ d: ["2026-02-01"] })
|
|
@@ -312,7 +353,7 @@ export declare class DateTimeExprNamespace {
|
|
|
312
353
|
*/
|
|
313
354
|
ordinal_day(): any;
|
|
314
355
|
/**
|
|
315
|
-
*
|
|
356
|
+
* Extracts the calendar quarter of the year (1-4) from a Datetime column.
|
|
316
357
|
* @returns ColumnExpression
|
|
317
358
|
* @example
|
|
318
359
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -326,7 +367,25 @@ export declare class DateTimeExprNamespace {
|
|
|
326
367
|
*/
|
|
327
368
|
quarter(): any;
|
|
328
369
|
/**
|
|
329
|
-
*
|
|
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.
|
|
330
389
|
* @returns ColumnExpression
|
|
331
390
|
* @example
|
|
332
391
|
* >>> const df = $df.data({ ts: ["2026-05-20T10:00:45Z"] })
|
|
@@ -340,8 +399,9 @@ export declare class DateTimeExprNamespace {
|
|
|
340
399
|
*/
|
|
341
400
|
second(): any;
|
|
342
401
|
/**
|
|
343
|
-
* Formats
|
|
344
|
-
*
|
|
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.
|
|
345
405
|
* @returns ColumnExpression
|
|
346
406
|
* @example
|
|
347
407
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -355,7 +415,7 @@ export declare class DateTimeExprNamespace {
|
|
|
355
415
|
*/
|
|
356
416
|
strftime(options: StrftimeOptions): any;
|
|
357
417
|
/**
|
|
358
|
-
* Extracts time component string ("HH:MM:SS.mmm").
|
|
418
|
+
* Extracts the time component formatted string (`"HH:MM:SS.mmm"`) from a Datetime column.
|
|
359
419
|
* @returns ColumnExpression
|
|
360
420
|
* @example
|
|
361
421
|
* >>> const df = $df.data({ ts: ["2026-05-20T10:30:00Z"] })
|
|
@@ -384,22 +444,7 @@ export declare class DateTimeExprNamespace {
|
|
|
384
444
|
*/
|
|
385
445
|
timestamp(unit?: TimeUnit): any;
|
|
386
446
|
/**
|
|
387
|
-
*
|
|
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.
|
|
447
|
+
* Converts a Duration value (in milliseconds) to total days count.
|
|
403
448
|
* @returns ColumnExpression
|
|
404
449
|
* @example
|
|
405
450
|
* >>> const df = $df.data({ dur: [86400000] })
|
|
@@ -413,7 +458,7 @@ export declare class DateTimeExprNamespace {
|
|
|
413
458
|
*/
|
|
414
459
|
total_days(): any;
|
|
415
460
|
/**
|
|
416
|
-
* Converts Duration to
|
|
461
|
+
* Converts a Duration value (in milliseconds) to total hours count.
|
|
417
462
|
* @returns ColumnExpression
|
|
418
463
|
* @example
|
|
419
464
|
* >>> const df = $df.data({ dur: [3600000] })
|
|
@@ -497,9 +542,13 @@ export declare class DateTimeExprNamespace {
|
|
|
497
542
|
*/
|
|
498
543
|
total_seconds(): any;
|
|
499
544
|
/**
|
|
500
|
-
* Returns the offset of
|
|
501
|
-
*
|
|
502
|
-
*
|
|
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"`).
|
|
503
552
|
* @returns ColumnExpression
|
|
504
553
|
* @example
|
|
505
554
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -528,6 +577,7 @@ export declare class DateTimeExprNamespace {
|
|
|
528
577
|
week(): any;
|
|
529
578
|
/**
|
|
530
579
|
* Extracts weekday component (1=Monday, 7=Sunday).
|
|
580
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to UTC.
|
|
531
581
|
* @returns ColumnExpression
|
|
532
582
|
* @example
|
|
533
583
|
* >>> const df = $df.data({ d: ["2026-05-18"] })
|
|
@@ -539,9 +589,10 @@ export declare class DateTimeExprNamespace {
|
|
|
539
589
|
* │ 2026-05-18 │ 1 │
|
|
540
590
|
* └────────────┴────┘
|
|
541
591
|
*/
|
|
542
|
-
weekday(): any;
|
|
592
|
+
weekday(timeZone?: string): any;
|
|
543
593
|
/**
|
|
544
594
|
* Extracts the year component from a Datetime column.
|
|
595
|
+
* @param timeZone Optional IANA timezone identifier. Defaults to UTC.
|
|
545
596
|
* @returns ColumnExpression
|
|
546
597
|
* @example
|
|
547
598
|
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
@@ -553,7 +604,7 @@ export declare class DateTimeExprNamespace {
|
|
|
553
604
|
* │ 2026-05-20 │ 2026 │
|
|
554
605
|
* └────────────┴──────┘
|
|
555
606
|
*/
|
|
556
|
-
year(): any;
|
|
607
|
+
year(timeZone?: string): any;
|
|
557
608
|
}
|
|
558
609
|
export declare class TemporalExpr extends ExprBase {
|
|
559
610
|
/**
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type { IExpr, ColumnData, ColumnDict } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a single unary value (coercing Date instances to getTime if valid)
|
|
4
|
+
* and executes the operation callback.
|
|
5
|
+
*/
|
|
6
|
+
export declare function evalUnaryOp(v: any, fn: (a: any) => any): any;
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes binary values (coercing Date instances to getTime if valid)
|
|
9
|
+
* and executes the operation callback.
|
|
10
|
+
*/
|
|
11
|
+
export declare function evalBinaryOp(v: any, r: any, fn: (a: any, b: any) => any): any;
|
|
2
12
|
export declare const kleeneUnary: (fn: (v: any) => any) => (vArray: ColumnData) => any[];
|
|
3
13
|
export declare const kleeneBinary: (expr: IExpr, other: any, fn: (v: any, r: any) => any) => (vArray: ColumnData, columns: ColumnDict) => any[];
|
|
4
14
|
export declare function evaluateExpression(expr: IExpr, columns: ColumnDict, height: number): ColumnData;
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
export declare const NEWLINE = "\n";
|
|
2
2
|
export declare const CARRIAGE_RETURN = "\r";
|
|
3
3
|
export declare const UTF8_BOM = "\uFEFF";
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const MS_PER_MINUTE = 60000;
|
|
6
|
-
export declare const MS_PER_HOUR = 3600000;
|
|
4
|
+
export declare const MS_PER_WEEK = 604800000;
|
|
7
5
|
export declare const MS_PER_DAY = 86400000;
|
|
6
|
+
export declare const MS_PER_HOUR = 3600000;
|
|
7
|
+
export declare const MS_PER_MINUTE = 60000;
|
|
8
|
+
export declare const MS_PER_SECOND = 1000;
|
|
9
|
+
export declare const MS_PER_MILLISECOND = 1;
|
|
10
|
+
export declare const MS_PER_MICROSECOND = 0.001;
|
|
11
|
+
export declare const MS_PER_NANOSECOND = 0.000001;
|
|
8
12
|
export declare const US_PER_MS = 1000;
|
|
9
13
|
export declare const NS_PER_MS = 1000000;
|
|
10
14
|
export declare const US_PER_MS_BI = 1000n;
|
|
11
15
|
export declare const NS_PER_MS_BI = 1000000n;
|
|
16
|
+
/** Separates composite key segments within a single row hash (e.g. multi-column join keys). */
|
|
17
|
+
export declare const KEY_SEPARATOR = "\0";
|
|
18
|
+
/** Separates key-value pairs within a serialized object or map canonical hash. */
|
|
19
|
+
export declare const KEY_PAIR_SEPARATOR = "\u0001";
|
|
20
|
+
/** Sentinel value used in join left-index arrays to indicate a right-only (unmatched) row. */
|
|
21
|
+
export declare const UNMATCHED_ROW_INDEX = -1;
|
|
22
|
+
/** Maximum allowable length for a single JavaScript array (2^32 - 1). */
|
|
23
|
+
export declare const MAX_JS_ARRAY_LENGTH = 4294967295;
|