df-script 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/api.d.ts +2 -1
- package/dist/assets/index-DBhGK6Tp.css +1 -0
- package/dist/assets/index-DEJEV_tU.js +195 -0
- package/dist/columnExpressions/ColumnExpr.d.ts +12 -5
- package/dist/columnExpressions/ExprBase.d.ts +26 -12
- package/dist/columnExpressions/constants.d.ts +1 -0
- package/dist/columnExpressions/functions/all.d.ts +23 -0
- package/dist/columnExpressions/functions/coalesce.d.ts +29 -0
- package/dist/columnExpressions/functions/element.d.ts +25 -0
- package/dist/columnExpressions/functions/exclude.d.ts +24 -0
- package/dist/columnExpressions/functions/implode.d.ts +28 -0
- package/dist/columnExpressions/functions/lit.d.ts +27 -0
- package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
- package/dist/columnExpressions/functions/struct.d.ts +31 -0
- package/dist/columnExpressions/functions/when.d.ts +36 -6
- package/dist/columnExpressions/index.d.ts +1 -0
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +334 -0
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +609 -0
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +533 -5
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +656 -3
- package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +530 -4
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
- package/dist/columnExpressions/types.d.ts +1 -0
- package/dist/dataframe/dataframe.d.ts +932 -2
- package/dist/dataframe/grouped/grouped.d.ts +41 -6
- package/dist/dataframe/types.d.ts +1 -0
- package/dist/dataframe/utils.d.ts +1 -0
- package/dist/datatypes/types.d.ts +45 -0
- package/dist/exceptions/index.d.ts +23 -0
- package/dist/functions/concat.d.ts +50 -0
- package/dist/functions/read_csv.d.ts +9 -0
- package/dist/functions/read_json.d.ts +7 -2
- package/dist/index.html +17 -0
- package/dist/index.js +5 -5
- package/dist/index.mjs +6 -0
- package/dist/types.d.ts +47 -14
- package/dist/utils/array.d.ts +32 -1
- package/dist/utils/csv.d.ts +1 -0
- package/dist/utils/date.d.ts +10 -27
- package/dist/utils/json.d.ts +1 -0
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/string.d.ts +12 -0
- package/package.json +18 -4
- package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
- package/dist/utils/guards.d.ts +0 -13
- package/dist/utils/list.d.ts +0 -217
|
@@ -1,43 +1,652 @@
|
|
|
1
1
|
import type { RandomOptions, NumericArg } from "../types";
|
|
2
2
|
import { ExprBase } from "../ExprBase";
|
|
3
|
+
/**
|
|
4
|
+
* @namespace $df.col
|
|
5
|
+
* @category ColumnExpression
|
|
6
|
+
* @syntax $df.col(<column_name>).{symbol}(...)
|
|
7
|
+
*/
|
|
3
8
|
export declare class ArithmeticExpr extends ExprBase {
|
|
9
|
+
/**
|
|
10
|
+
* Computes the absolute value of the column values.
|
|
11
|
+
* @returns ColumnExpression
|
|
12
|
+
* @example
|
|
13
|
+
* >>> const df = $df.data({ a: [-1, 2, -3.5] })
|
|
14
|
+
* >>> df.with_columns($df.col("a").abs().alias("abs_a"))
|
|
15
|
+
* shape: (3, 2)
|
|
16
|
+
* ┌──────┬───────┐
|
|
17
|
+
* │ a │ abs_a │
|
|
18
|
+
* ├──────┼───────┤
|
|
19
|
+
* │ -1 │ 1 │
|
|
20
|
+
* │ 2 │ 2 │
|
|
21
|
+
* │ -3.5 │ 3.5 │
|
|
22
|
+
* └──────┴───────┘
|
|
23
|
+
*/
|
|
4
24
|
abs(): this;
|
|
25
|
+
/**
|
|
26
|
+
* Computes the mathematical arccosine (inverse cosine) of the column values.
|
|
27
|
+
* @returns ColumnExpression
|
|
28
|
+
* @example
|
|
29
|
+
* >>> const df = $df.data({ a: [0, 0.5, 1] })
|
|
30
|
+
* >>> df.with_columns($df.col("a").acos().alias("acos_a"))
|
|
31
|
+
* shape: (3, 2)
|
|
32
|
+
* ┌─────┬───────────┐
|
|
33
|
+
* │ a │ acos_a │
|
|
34
|
+
* ├─────┼───────────┤
|
|
35
|
+
* │ 0 │ 1.570796 │
|
|
36
|
+
* │ 0.5 │ 1.047197 │
|
|
37
|
+
* │ 1 │ 0 │
|
|
38
|
+
* └─────┴───────────┘
|
|
39
|
+
*/
|
|
5
40
|
acos(): this;
|
|
41
|
+
/**
|
|
42
|
+
* Computes the hyperbolic arccosine of the column values.
|
|
43
|
+
* @returns ColumnExpression
|
|
44
|
+
* @example
|
|
45
|
+
* >>> const df = $df.data({ a: [1, 2, 5] })
|
|
46
|
+
* >>> df.with_columns($df.col("a").acosh().alias("acosh_a"))
|
|
47
|
+
* shape: (3, 2)
|
|
48
|
+
* ┌───┬───────────┐
|
|
49
|
+
* │ a │ acosh_a │
|
|
50
|
+
* ├───┼───────────┤
|
|
51
|
+
* │ 1 │ 0 │
|
|
52
|
+
* │ 2 │ 1.316957 │
|
|
53
|
+
* │ 5 │ 2.292431 │
|
|
54
|
+
* └───┴───────────┘
|
|
55
|
+
*/
|
|
6
56
|
acosh(): this;
|
|
57
|
+
/**
|
|
58
|
+
* Adds a scalar value or another column expression.
|
|
59
|
+
* @param val The number or column expression to add.
|
|
60
|
+
* @returns ColumnExpression
|
|
61
|
+
* @example
|
|
62
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
63
|
+
* >>> df.with_columns($df.col("a").add(10).alias("added"))
|
|
64
|
+
* shape: (3, 2)
|
|
65
|
+
* ┌───┬───────┐
|
|
66
|
+
* │ a │ added │
|
|
67
|
+
* ├───┼───────┤
|
|
68
|
+
* │ 1 │ 11 │
|
|
69
|
+
* │ 2 │ 12 │
|
|
70
|
+
* │ 3 │ 13 │
|
|
71
|
+
* └───┴───────┘
|
|
72
|
+
*/
|
|
7
73
|
add(val: NumericArg): this;
|
|
74
|
+
/**
|
|
75
|
+
* Computes the arcsine of the column values.
|
|
76
|
+
* @returns ColumnExpression
|
|
77
|
+
* @example
|
|
78
|
+
* >>> const df = $df.data({ a: [0, 0.5, 1] })
|
|
79
|
+
* >>> df.with_columns($df.col("a").asin().alias("asin_a"))
|
|
80
|
+
* shape: (3, 2)
|
|
81
|
+
* ┌─────┬───────────┐
|
|
82
|
+
* │ a │ asin_a │
|
|
83
|
+
* ├─────┼───────────┤
|
|
84
|
+
* │ 0 │ 0 │
|
|
85
|
+
* │ 0.5 │ 0.523598 │
|
|
86
|
+
* │ 1 │ 1.570796 │
|
|
87
|
+
* └─────┴───────────┘
|
|
88
|
+
*/
|
|
8
89
|
asin(): this;
|
|
90
|
+
/**
|
|
91
|
+
* Computes the hyperbolic arcsine of the column values.
|
|
92
|
+
* @returns ColumnExpression
|
|
93
|
+
* @example
|
|
94
|
+
* >>> const df = $df.data({ a: [0, 1, 2] })
|
|
95
|
+
* >>> df.with_columns($df.col("a").asinh().alias("asinh_a"))
|
|
96
|
+
* shape: (3, 2)
|
|
97
|
+
* ┌───┬───────────┐
|
|
98
|
+
* │ a │ asinh_a │
|
|
99
|
+
* ├───┼───────────┤
|
|
100
|
+
* │ 0 │ 0 │
|
|
101
|
+
* │ 1 │ 0.881373 │
|
|
102
|
+
* │ 2 │ 1.443635 │
|
|
103
|
+
* └───┴───────────┘
|
|
104
|
+
*/
|
|
9
105
|
asinh(): this;
|
|
106
|
+
/**
|
|
107
|
+
* Computes the arctangent of the column values.
|
|
108
|
+
* @returns ColumnExpression
|
|
109
|
+
* @example
|
|
110
|
+
* >>> const df = $df.data({ a: [0, 1, 2] })
|
|
111
|
+
* >>> df.with_columns($df.col("a").atan().alias("atan_a"))
|
|
112
|
+
* shape: (3, 2)
|
|
113
|
+
* ┌───┬───────────┐
|
|
114
|
+
* │ a │ atan_a │
|
|
115
|
+
* ├───┼───────────┤
|
|
116
|
+
* │ 0 │ 0 │
|
|
117
|
+
* │ 1 │ 0.785398 │
|
|
118
|
+
* │ 2 │ 1.107148 │
|
|
119
|
+
* └───┴───────────┘
|
|
120
|
+
*/
|
|
10
121
|
atan(): this;
|
|
122
|
+
/**
|
|
123
|
+
* Computes the quadrant-aware arctangent of two values.
|
|
124
|
+
* @param val The x denominator number or column expression.
|
|
125
|
+
* @returns ColumnExpression
|
|
126
|
+
* @example
|
|
127
|
+
* >>> const df = $df.data({ a: [1, 2], b: [2, 1] })
|
|
128
|
+
* >>> df.with_columns($df.col("a").atan2($df.col("b")).alias("atan2_a"))
|
|
129
|
+
* shape: (2, 3)
|
|
130
|
+
* ┌───┬───┬───────────┐
|
|
131
|
+
* │ a │ b │ atan2_a │
|
|
132
|
+
* ├───┼───┼───────────┤
|
|
133
|
+
* │ 1 │ 2 │ 0.463647 │
|
|
134
|
+
* │ 2 │ 1 │ 1.107148 │
|
|
135
|
+
* └───┴───┴───────────┘
|
|
136
|
+
*/
|
|
11
137
|
atan2(val: NumericArg): this;
|
|
138
|
+
/**
|
|
139
|
+
* Computes the hyperbolic arctangent of the column values.
|
|
140
|
+
* @returns ColumnExpression
|
|
141
|
+
* @example
|
|
142
|
+
* >>> const df = $df.data({ a: [0, 0.5] })
|
|
143
|
+
* >>> df.with_columns($df.col("a").atanh().alias("atanh_a"))
|
|
144
|
+
* shape: (2, 2)
|
|
145
|
+
* ┌─────┬───────────┐
|
|
146
|
+
* │ a │ atanh_a │
|
|
147
|
+
* ├─────┼───────────┤
|
|
148
|
+
* │ 0 │ 0 │
|
|
149
|
+
* │ 0.5 │ 0.549306 │
|
|
150
|
+
* └─────┴───────────┘
|
|
151
|
+
*/
|
|
12
152
|
atanh(): this;
|
|
153
|
+
/**
|
|
154
|
+
* Computes the cube root of the column values.
|
|
155
|
+
* @returns ColumnExpression
|
|
156
|
+
* @example
|
|
157
|
+
* >>> const df = $df.data({ a: [1, 8, 27] })
|
|
158
|
+
* >>> df.with_columns($df.col("a").cbrt().alias("cbrt_a"))
|
|
159
|
+
* shape: (3, 2)
|
|
160
|
+
* ┌────┬────────┐
|
|
161
|
+
* │ a │ cbrt_a │
|
|
162
|
+
* ├────┼────────┤
|
|
163
|
+
* │ 1 │ 1 │
|
|
164
|
+
* │ 8 │ 2 │
|
|
165
|
+
* │ 27 │ 3 │
|
|
166
|
+
* └────┴────────┘
|
|
167
|
+
*/
|
|
13
168
|
cbrt(): this;
|
|
169
|
+
/**
|
|
170
|
+
* Rounds column values up to the nearest integer.
|
|
171
|
+
* @returns ColumnExpression
|
|
172
|
+
* @example
|
|
173
|
+
* >>> const df = $df.data({ a: [1.1, 2.8, -0.5] })
|
|
174
|
+
* >>> df.with_columns($df.col("a").ceil().alias("ceil_a"))
|
|
175
|
+
* shape: (3, 2)
|
|
176
|
+
* ┌──────┬────────┐
|
|
177
|
+
* │ a │ ceil_a │
|
|
178
|
+
* ├──────┼────────┤
|
|
179
|
+
* │ 1.1 │ 2 │
|
|
180
|
+
* │ 2.8 │ 3 │
|
|
181
|
+
* │ -0.5 │ 0 │
|
|
182
|
+
* └──────┴────────┘
|
|
183
|
+
*/
|
|
14
184
|
ceil(): this;
|
|
185
|
+
/**
|
|
186
|
+
* Clamps column values between lower and upper numeric thresholds.
|
|
187
|
+
* @param lower The lower threshold value (default: null).
|
|
188
|
+
* @param upper The upper threshold value (default: null).
|
|
189
|
+
* @returns ColumnExpression
|
|
190
|
+
* @example
|
|
191
|
+
* >>> const df = $df.data({ a: [5, 15, 25] })
|
|
192
|
+
* >>> df.with_columns($df.col("a").clip(10, 20).alias("clipped"))
|
|
193
|
+
* shape: (3, 2)
|
|
194
|
+
* ┌────┬─────────┐
|
|
195
|
+
* │ a │ clipped │
|
|
196
|
+
* ├────┼─────────┤
|
|
197
|
+
* │ 5 │ 10 │
|
|
198
|
+
* │ 15 │ 15 │
|
|
199
|
+
* │ 25 │ 20 │
|
|
200
|
+
* └────┴─────────┘
|
|
201
|
+
*/
|
|
15
202
|
clip(lower?: number | null, upper?: number | null): this;
|
|
203
|
+
/**
|
|
204
|
+
* Returns absolute value of expr with the sign of other.
|
|
205
|
+
* @param val The sign source value or column expression.
|
|
206
|
+
* @returns ColumnExpression
|
|
207
|
+
* @example
|
|
208
|
+
* >>> const df = $df.data({ a: [5, 10], b: [-1, 1] })
|
|
209
|
+
* >>> df.with_columns($df.col("a").copysign($df.col("b")).alias("signed"))
|
|
210
|
+
* shape: (2, 3)
|
|
211
|
+
* ┌────┬────┬────────┐
|
|
212
|
+
* │ a │ b │ signed │
|
|
213
|
+
* ├────┼────┼────────┤
|
|
214
|
+
* │ 5 │ -1 │ -5 │
|
|
215
|
+
* │ 10 │ 1 │ 10 │
|
|
216
|
+
* └────┴────┴────────┘
|
|
217
|
+
*/
|
|
16
218
|
copysign(val: NumericArg): this;
|
|
219
|
+
/**
|
|
220
|
+
* Computes the cosine of the column values.
|
|
221
|
+
* @returns ColumnExpression
|
|
222
|
+
* @example
|
|
223
|
+
* >>> const df = $df.data({ a: [0, Math.PI] })
|
|
224
|
+
* >>> df.with_columns($df.col("a").cos().alias("cos_a"))
|
|
225
|
+
* shape: (2, 2)
|
|
226
|
+
* ┌───────┬───────┐
|
|
227
|
+
* │ a │ cos_a │
|
|
228
|
+
* ├───────┼───────┤
|
|
229
|
+
* │ 0 │ 1 │
|
|
230
|
+
* │ 3.141 │ -1 │
|
|
231
|
+
* └───────┴───────┘
|
|
232
|
+
*/
|
|
17
233
|
cos(): this;
|
|
234
|
+
/**
|
|
235
|
+
* Computes the hyperbolic cosine of the column values.
|
|
236
|
+
* @returns ColumnExpression
|
|
237
|
+
* @example
|
|
238
|
+
* >>> const df = $df.data({ a: [0, 1] })
|
|
239
|
+
* >>> df.with_columns($df.col("a").cosh().alias("cosh_a"))
|
|
240
|
+
* shape: (2, 2)
|
|
241
|
+
* ┌───┬───────────┐
|
|
242
|
+
* │ a │ cosh_a │
|
|
243
|
+
* ├───┼───────────┤
|
|
244
|
+
* │ 0 │ 1 │
|
|
245
|
+
* │ 1 │ 1.543080 │
|
|
246
|
+
* └───┴───────────┘
|
|
247
|
+
*/
|
|
18
248
|
cosh(): this;
|
|
249
|
+
/**
|
|
250
|
+
* Converts angles from radians to degrees.
|
|
251
|
+
* @returns ColumnExpression
|
|
252
|
+
* @example
|
|
253
|
+
* >>> const df = $df.data({ a: [0, Math.PI] })
|
|
254
|
+
* >>> df.with_columns($df.col("a").degrees().alias("deg"))
|
|
255
|
+
* shape: (2, 2)
|
|
256
|
+
* ┌───────┬─────┐
|
|
257
|
+
* │ a │ deg │
|
|
258
|
+
* ├───────┼─────┤
|
|
259
|
+
* │ 0 │ 0 │
|
|
260
|
+
* │ 3.141 │ 180 │
|
|
261
|
+
* └───────┴─────┘
|
|
262
|
+
*/
|
|
19
263
|
degrees(): this;
|
|
264
|
+
/**
|
|
265
|
+
* Divides column values by a scalar or another column expression.
|
|
266
|
+
* @param val The denominator value or column expression.
|
|
267
|
+
* @returns ColumnExpression
|
|
268
|
+
* @example
|
|
269
|
+
* >>> const df = $df.data({ a: [10, 20, 30] })
|
|
270
|
+
* >>> df.with_columns($df.col("a").div(2).alias("div_a"))
|
|
271
|
+
* shape: (3, 2)
|
|
272
|
+
* ┌────┬───────┐
|
|
273
|
+
* │ a │ div_a │
|
|
274
|
+
* ├────┼───────┤
|
|
275
|
+
* │ 10 │ 5 │
|
|
276
|
+
* │ 20 │ 10 │
|
|
277
|
+
* │ 30 │ 15 │
|
|
278
|
+
* └────┴───────┘
|
|
279
|
+
*/
|
|
20
280
|
div(val: NumericArg): this;
|
|
281
|
+
/**
|
|
282
|
+
* Computes natural exponent (e^x) of the column values.
|
|
283
|
+
* @returns ColumnExpression
|
|
284
|
+
* @example
|
|
285
|
+
* >>> const df = $df.data({ a: [0, 1, 2] })
|
|
286
|
+
* >>> df.with_columns($df.col("a").exp().alias("exp_a"))
|
|
287
|
+
* shape: (3, 2)
|
|
288
|
+
* ┌───┬──────────┐
|
|
289
|
+
* │ a │ exp_a │
|
|
290
|
+
* ├───┼──────────┤
|
|
291
|
+
* │ 0 │ 1 │
|
|
292
|
+
* │ 1 │ 2.718281 │
|
|
293
|
+
* │ 2 │ 7.389056 │
|
|
294
|
+
* └───┴──────────┘
|
|
295
|
+
*/
|
|
21
296
|
exp(): this;
|
|
297
|
+
/**
|
|
298
|
+
* Computes e^x - 1 for each element in the column.
|
|
299
|
+
* @returns ColumnExpression
|
|
300
|
+
* @example
|
|
301
|
+
* >>> const df = $df.data({ a: [0, 1, 2] })
|
|
302
|
+
* >>> df.with_columns($df.col("a").expm1().alias("expm1_a"))
|
|
303
|
+
* shape: (3, 2)
|
|
304
|
+
* ┌───┬──────────┐
|
|
305
|
+
* │ a │ expm1_a │
|
|
306
|
+
* ├───┼──────────┤
|
|
307
|
+
* │ 0 │ 0 │
|
|
308
|
+
* │ 1 │ 1.718281 │
|
|
309
|
+
* │ 2 │ 6.389056 │
|
|
310
|
+
* └───┴──────────┘
|
|
311
|
+
*/
|
|
22
312
|
expm1(): this;
|
|
313
|
+
/**
|
|
314
|
+
* Rounds column values down to the nearest integer.
|
|
315
|
+
* @returns ColumnExpression
|
|
316
|
+
* @example
|
|
317
|
+
* >>> const df = $df.data({ a: [1.1, 2.8, -0.5] })
|
|
318
|
+
* >>> df.with_columns($df.col("a").floor().alias("floor_a"))
|
|
319
|
+
* shape: (3, 2)
|
|
320
|
+
* ┌──────┬─────────┐
|
|
321
|
+
* │ a │ floor_a │
|
|
322
|
+
* ├──────┼─────────┤
|
|
323
|
+
* │ 1.1 │ 1 │
|
|
324
|
+
* │ 2.8 │ 2 │
|
|
325
|
+
* │ -0.5 │ -1 │
|
|
326
|
+
* └──────┴─────────┘
|
|
327
|
+
*/
|
|
23
328
|
floor(): this;
|
|
329
|
+
/**
|
|
330
|
+
* Performs integer division floor(x / y) on column values.
|
|
331
|
+
* @param val The divisor value or column expression.
|
|
332
|
+
* @returns ColumnExpression
|
|
333
|
+
* @example
|
|
334
|
+
* >>> const df = $df.data({ a: [5, 10, 15] })
|
|
335
|
+
* >>> df.with_columns($df.col("a").floordiv(2).alias("fdiv"))
|
|
336
|
+
* shape: (3, 2)
|
|
337
|
+
* ┌────┬──────┐
|
|
338
|
+
* │ a │ fdiv │
|
|
339
|
+
* ├────┼──────┤
|
|
340
|
+
* │ 5 │ 2 │
|
|
341
|
+
* │ 10 │ 5 │
|
|
342
|
+
* │ 15 │ 7 │
|
|
343
|
+
* └────┴──────┘
|
|
344
|
+
*/
|
|
24
345
|
floordiv(val: NumericArg): this;
|
|
346
|
+
/**
|
|
347
|
+
* Computes the hypotenuse sqrt(x^2 + y^2) of two values.
|
|
348
|
+
* @param val The other numeric value or column expression.
|
|
349
|
+
* @returns ColumnExpression
|
|
350
|
+
* @example
|
|
351
|
+
* >>> const df = $df.data({ a: [3, 5], b: [4, 12] })
|
|
352
|
+
* >>> df.with_columns($df.col("a").hypot($df.col("b")).alias("hypot_a"))
|
|
353
|
+
* shape: (2, 3)
|
|
354
|
+
* ┌───┬────┬─────────┐
|
|
355
|
+
* │ a │ b │ hypot_a │
|
|
356
|
+
* ├───┼────┼─────────┤
|
|
357
|
+
* │ 3 │ 4 │ 5 │
|
|
358
|
+
* │ 5 │ 12 │ 13 │
|
|
359
|
+
* └───┴────┴─────────┘
|
|
360
|
+
*/
|
|
25
361
|
hypot(val: NumericArg): this;
|
|
362
|
+
/**
|
|
363
|
+
* Computes the logarithm of positive values with a specified base.
|
|
364
|
+
* @param base The base of the logarithm (default: Math.E).
|
|
365
|
+
* @returns ColumnExpression
|
|
366
|
+
* @example
|
|
367
|
+
* >>> const df = $df.data({ a: [1, 10, 100] })
|
|
368
|
+
* >>> df.with_columns($df.col("a").log(10).alias("log_a"))
|
|
369
|
+
* shape: (3, 2)
|
|
370
|
+
* ┌─────┬───────┐
|
|
371
|
+
* │ a │ log_a │
|
|
372
|
+
* ├─────┼───────┤
|
|
373
|
+
* │ 1 │ 0 │
|
|
374
|
+
* │ 10 │ 1 │
|
|
375
|
+
* │ 100 │ 2 │
|
|
376
|
+
* └─────┴───────┘
|
|
377
|
+
*/
|
|
26
378
|
log(base?: number): this;
|
|
379
|
+
/**
|
|
380
|
+
* Computes natural logarithm of 1 + x.
|
|
381
|
+
* @returns ColumnExpression
|
|
382
|
+
* @example
|
|
383
|
+
* >>> const df = $df.data({ a: [0, 1, 2] })
|
|
384
|
+
* >>> df.with_columns($df.col("a").log1p().alias("log1p_a"))
|
|
385
|
+
* shape: (3, 2)
|
|
386
|
+
* ┌───┬──────────┐
|
|
387
|
+
* │ a │ log1p_a │
|
|
388
|
+
* ├───┼──────────┤
|
|
389
|
+
* │ 0 │ 0 │
|
|
390
|
+
* │ 1 │ 0.693147 │
|
|
391
|
+
* │ 2 │ 1.098612 │
|
|
392
|
+
* └───┴──────────┘
|
|
393
|
+
*/
|
|
27
394
|
log1p(): this;
|
|
395
|
+
/**
|
|
396
|
+
* Computes modulo remainder (x % y) of column values.
|
|
397
|
+
* @param val The divisor value or column expression.
|
|
398
|
+
* @returns ColumnExpression
|
|
399
|
+
* @example
|
|
400
|
+
* >>> const df = $df.data({ a: [10, 11, 12] })
|
|
401
|
+
* >>> df.with_columns($df.col("a").mod(2).alias("mod_a"))
|
|
402
|
+
* shape: (3, 2)
|
|
403
|
+
* ┌────┬───────┐
|
|
404
|
+
* │ a │ mod_a │
|
|
405
|
+
* ├────┼───────┤
|
|
406
|
+
* │ 10 │ 0 │
|
|
407
|
+
* │ 11 │ 1 │
|
|
408
|
+
* │ 12 │ 0 │
|
|
409
|
+
* └────┴───────┘
|
|
410
|
+
*/
|
|
28
411
|
mod(val: NumericArg): this;
|
|
412
|
+
/**
|
|
413
|
+
* Multiplies column values by a scalar or another column expression.
|
|
414
|
+
* @param val The multiplier value or column expression.
|
|
415
|
+
* @returns ColumnExpression
|
|
416
|
+
* @example
|
|
417
|
+
* >>> const df = $df.data({ a: [1, 2, 3] })
|
|
418
|
+
* >>> df.with_columns($df.col("a").mul(5).alias("multiplied"))
|
|
419
|
+
* shape: (3, 2)
|
|
420
|
+
* ┌───┬────────────┐
|
|
421
|
+
* │ a │ multiplied │
|
|
422
|
+
* ├───┼────────────┤
|
|
423
|
+
* │ 1 │ 5 │
|
|
424
|
+
* │ 2 │ 10 │
|
|
425
|
+
* │ 3 │ 15 │
|
|
426
|
+
* └───┴────────────┘
|
|
427
|
+
*/
|
|
29
428
|
mul(val: NumericArg): this;
|
|
429
|
+
/**
|
|
430
|
+
* Negates column values (-x).
|
|
431
|
+
* @returns ColumnExpression
|
|
432
|
+
* @example
|
|
433
|
+
* >>> const df = $df.data({ a: [1, -2, 3] })
|
|
434
|
+
* >>> df.with_columns($df.col("a").negate().alias("negated"))
|
|
435
|
+
* shape: (3, 2)
|
|
436
|
+
* ┌────┬─────────┐
|
|
437
|
+
* │ a │ negated │
|
|
438
|
+
* ├────┼─────────┤
|
|
439
|
+
* │ 1 │ -1 │
|
|
440
|
+
* │ -2 │ 2 │
|
|
441
|
+
* │ 3 │ -3 │
|
|
442
|
+
* └────┴─────────┘
|
|
443
|
+
*/
|
|
30
444
|
negate(): this;
|
|
445
|
+
/**
|
|
446
|
+
* Raises column values to the specified power.
|
|
447
|
+
* @param val The exponent power value or column expression.
|
|
448
|
+
* @returns ColumnExpression
|
|
449
|
+
* @example
|
|
450
|
+
* >>> const df = $df.data({ a: [2, 3, 4] })
|
|
451
|
+
* >>> df.with_columns($df.col("a").pow(2).alias("pow_a"))
|
|
452
|
+
* shape: (3, 2)
|
|
453
|
+
* ┌───┬───────┐
|
|
454
|
+
* │ a │ pow_a │
|
|
455
|
+
* ├───┼───────┤
|
|
456
|
+
* │ 2 │ 4 │
|
|
457
|
+
* │ 3 │ 9 │
|
|
458
|
+
* │ 4 │ 16 │
|
|
459
|
+
* └───┴───────┘
|
|
460
|
+
*/
|
|
31
461
|
pow(val: NumericArg): this;
|
|
462
|
+
/**
|
|
463
|
+
* Converts angles from degrees to radians.
|
|
464
|
+
* @returns ColumnExpression
|
|
465
|
+
* @example
|
|
466
|
+
* >>> const df = $df.data({ a: [0, 180] })
|
|
467
|
+
* >>> df.with_columns($df.col("a").radians().alias("rad"))
|
|
468
|
+
* shape: (2, 2)
|
|
469
|
+
* ┌─────┬──────────┐
|
|
470
|
+
* │ a │ rad │
|
|
471
|
+
* ├─────┼──────────┤
|
|
472
|
+
* │ 0 │ 0 │
|
|
473
|
+
* │ 180 │ 3.141592 │
|
|
474
|
+
* └─────┴──────────┘
|
|
475
|
+
*/
|
|
32
476
|
radians(): this;
|
|
477
|
+
/**
|
|
478
|
+
* Fills sequence with pseudo-random generated floats or integers.
|
|
479
|
+
* @param seed Optional seed to initialize the pseudo-random generator.
|
|
480
|
+
* @param options Config options including min, max, and integer flag.
|
|
481
|
+
* @returns ColumnExpression
|
|
482
|
+
* @example
|
|
483
|
+
* >>> const df = $df.data({ index: [1, 2, 3] })
|
|
484
|
+
* >>> df.with_columns($df.col("index").rand(42, { min: 1, max: 10, integer: true }).alias("random"))
|
|
485
|
+
* shape: (3, 2)
|
|
486
|
+
* ┌───────┬────────┐
|
|
487
|
+
* │ index │ random │
|
|
488
|
+
* ├───────┼────────┤
|
|
489
|
+
* │ 1 │ 2 │
|
|
490
|
+
* │ 2 │ 5 │
|
|
491
|
+
* │ 3 │ 6 │
|
|
492
|
+
* └───────┴────────┘
|
|
493
|
+
*/
|
|
33
494
|
rand(seed?: number, { min, max, integer }?: RandomOptions): this;
|
|
495
|
+
/**
|
|
496
|
+
* Rounds values to a specific scale of decimal digits.
|
|
497
|
+
* @param decimals Number of decimal places to round to (default: 0).
|
|
498
|
+
* @returns ColumnExpression
|
|
499
|
+
* @example
|
|
500
|
+
* >>> const df = $df.data({ a: [1.123, 2.789] })
|
|
501
|
+
* >>> df.with_columns($df.col("a").round(2).alias("rounded"))
|
|
502
|
+
* shape: (2, 2)
|
|
503
|
+
* ┌───────┬─────────┐
|
|
504
|
+
* │ a │ rounded │
|
|
505
|
+
* ├───────┼─────────┤
|
|
506
|
+
* │ 1.123 │ 1.12 │
|
|
507
|
+
* │ 2.789 │ 2.79 │
|
|
508
|
+
* └───────┴─────────┘
|
|
509
|
+
*/
|
|
34
510
|
round(decimals?: number): this;
|
|
511
|
+
/**
|
|
512
|
+
* Rounds values to a specific number of significant figures.
|
|
513
|
+
* @param sig_figs Number of significant figures.
|
|
514
|
+
* @returns ColumnExpression
|
|
515
|
+
* @example
|
|
516
|
+
* >>> const df = $df.data({ a: [123.45, 0.006789] })
|
|
517
|
+
* >>> df.with_columns($df.col("a").round_sig_figs(3).alias("sig_figs"))
|
|
518
|
+
* shape: (2, 2)
|
|
519
|
+
* ┌──────────┬──────────┐
|
|
520
|
+
* │ a │ sig_figs │
|
|
521
|
+
* ├──────────┼──────────┤
|
|
522
|
+
* │ 123.45 │ 123 │
|
|
523
|
+
* │ 0.006789 │ 0.00679 │
|
|
524
|
+
* └──────────┴──────────┘
|
|
525
|
+
*/
|
|
526
|
+
round_sig_figs(sig_figs: number): this;
|
|
527
|
+
/**
|
|
528
|
+
* Returns sign indicator of column values (-1, 0, or 1).
|
|
529
|
+
* @returns ColumnExpression
|
|
530
|
+
* @example
|
|
531
|
+
* >>> const df = $df.data({ a: [-10, 0, 50] })
|
|
532
|
+
* >>> df.with_columns($df.col("a").sign().alias("sign_a"))
|
|
533
|
+
* shape: (3, 2)
|
|
534
|
+
* ┌─────┬────────┐
|
|
535
|
+
* │ a │ sign_a │
|
|
536
|
+
* ├─────┼────────┤
|
|
537
|
+
* │ -10 │ -1 │
|
|
538
|
+
* │ 0 │ 0 │
|
|
539
|
+
* │ 50 │ 1 │
|
|
540
|
+
* └─────┴────────┘
|
|
541
|
+
*/
|
|
35
542
|
sign(): this;
|
|
543
|
+
/**
|
|
544
|
+
* Computes the sine of the column values.
|
|
545
|
+
* @returns ColumnExpression
|
|
546
|
+
* @example
|
|
547
|
+
* >>> const df = $df.data({ a: [0, Math.PI / 2] })
|
|
548
|
+
* >>> df.with_columns($df.col("a").sin().alias("sin_a"))
|
|
549
|
+
* shape: (2, 2)
|
|
550
|
+
* ┌───────┬───────┐
|
|
551
|
+
* │ a │ sin_a │
|
|
552
|
+
* ├───────┼───────┤
|
|
553
|
+
* │ 0 │ 0 │
|
|
554
|
+
* │ 1.570 │ 1 │
|
|
555
|
+
* └───────┴───────┘
|
|
556
|
+
*/
|
|
36
557
|
sin(): this;
|
|
558
|
+
/**
|
|
559
|
+
* Computes the hyperbolic sine of the column values.
|
|
560
|
+
* @returns ColumnExpression
|
|
561
|
+
* @example
|
|
562
|
+
* >>> const df = $df.data({ a: [0, 1] })
|
|
563
|
+
* >>> df.with_columns($df.col("a").sinh().alias("sinh_a"))
|
|
564
|
+
* shape: (2, 2)
|
|
565
|
+
* ┌───┬───────────┐
|
|
566
|
+
* │ a │ sinh_a │
|
|
567
|
+
* ├───┼───────────┤
|
|
568
|
+
* │ 0 │ 0 │
|
|
569
|
+
* │ 1 │ 1.175201 │
|
|
570
|
+
* └───┴───────────┘
|
|
571
|
+
*/
|
|
37
572
|
sinh(): this;
|
|
573
|
+
/**
|
|
574
|
+
* Computes the square root of non-negative column values.
|
|
575
|
+
* @returns ColumnExpression
|
|
576
|
+
* @example
|
|
577
|
+
* >>> const df = $df.data({ a: [4, 9, 16] })
|
|
578
|
+
* >>> df.with_columns($df.col("a").sqrt().alias("sqrt_a"))
|
|
579
|
+
* shape: (3, 2)
|
|
580
|
+
* ┌────┬────────┐
|
|
581
|
+
* │ a │ sqrt_a │
|
|
582
|
+
* ├────┼────────┤
|
|
583
|
+
* │ 4 │ 2 │
|
|
584
|
+
* │ 9 │ 3 │
|
|
585
|
+
* │ 16 │ 4 │
|
|
586
|
+
* └────┴────────┘
|
|
587
|
+
*/
|
|
38
588
|
sqrt(): this;
|
|
589
|
+
/**
|
|
590
|
+
* Subtracts a scalar or another column expression.
|
|
591
|
+
* @param val The value or column expression to subtract.
|
|
592
|
+
* @returns ColumnExpression
|
|
593
|
+
* @example
|
|
594
|
+
* >>> const df = $df.data({ a: [10, 20, 30] })
|
|
595
|
+
* >>> df.with_columns($df.col("a").sub(5).alias("sub_a"))
|
|
596
|
+
* shape: (3, 2)
|
|
597
|
+
* ┌────┬───────┐
|
|
598
|
+
* │ a │ sub_a │
|
|
599
|
+
* ├────┼───────┤
|
|
600
|
+
* │ 10 │ 5 │
|
|
601
|
+
* │ 20 │ 15 │
|
|
602
|
+
* │ 30 │ 25 │
|
|
603
|
+
* └────┴───────┘
|
|
604
|
+
*/
|
|
39
605
|
sub(val: NumericArg): this;
|
|
606
|
+
/**
|
|
607
|
+
* Computes the tangent of the column values.
|
|
608
|
+
* @returns ColumnExpression
|
|
609
|
+
* @example
|
|
610
|
+
* >>> const df = $df.data({ a: [0, Math.PI / 4] })
|
|
611
|
+
* >>> df.with_columns($df.col("a").tan().alias("tan_a"))
|
|
612
|
+
* shape: (2, 2)
|
|
613
|
+
* ┌───────┬───────┐
|
|
614
|
+
* │ a │ tan_a │
|
|
615
|
+
* ├───────┼───────┤
|
|
616
|
+
* │ 0 │ 0 │
|
|
617
|
+
* │ 0.785 │ 1 │
|
|
618
|
+
* └───────┴───────┘
|
|
619
|
+
*/
|
|
40
620
|
tan(): this;
|
|
621
|
+
/**
|
|
622
|
+
* Computes the hyperbolic tangent of the column values.
|
|
623
|
+
* @returns ColumnExpression
|
|
624
|
+
* @example
|
|
625
|
+
* >>> const df = $df.data({ a: [0, 1] })
|
|
626
|
+
* >>> df.with_columns($df.col("a").tanh().alias("tanh_a"))
|
|
627
|
+
* shape: (2, 2)
|
|
628
|
+
* ┌───┬───────────┐
|
|
629
|
+
* │ a │ tanh_a │
|
|
630
|
+
* ├───┼───────────┤
|
|
631
|
+
* │ 0 │ 0 │
|
|
632
|
+
* │ 1 │ 0.761594 │
|
|
633
|
+
* └───┴───────────┘
|
|
634
|
+
*/
|
|
41
635
|
tanh(): this;
|
|
636
|
+
/**
|
|
637
|
+
* Truncates fractional digits of column values.
|
|
638
|
+
* @returns ColumnExpression
|
|
639
|
+
* @example
|
|
640
|
+
* >>> const df = $df.data({ a: [1.1, 2.9, -3.5] })
|
|
641
|
+
* >>> df.with_columns($df.col("a").trunc().alias("trunc_a"))
|
|
642
|
+
* shape: (3, 2)
|
|
643
|
+
* ┌──────┬─────────┐
|
|
644
|
+
* │ a │ trunc_a │
|
|
645
|
+
* ├──────┼─────────┤
|
|
646
|
+
* │ 1.1 │ 1 │
|
|
647
|
+
* │ 2.9 │ 2 │
|
|
648
|
+
* │ -3.5 │ -3 │
|
|
649
|
+
* └──────┴─────────┘
|
|
650
|
+
*/
|
|
42
651
|
trunc(): this;
|
|
43
652
|
}
|