@ohos-ports/nodejs-polars 0.23.4-beta.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 (71) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +217 -0
  3. package/bin/cfg.d.ts +156 -0
  4. package/bin/cfg.js +52 -0
  5. package/bin/dataframe.d.ts +2135 -0
  6. package/bin/dataframe.js +783 -0
  7. package/bin/datatypes/conversion.d.ts +2 -0
  8. package/bin/datatypes/conversion.js +2 -0
  9. package/bin/datatypes/datatype.d.ts +285 -0
  10. package/bin/datatypes/datatype.js +430 -0
  11. package/bin/datatypes/field.d.ts +26 -0
  12. package/bin/datatypes/field.js +36 -0
  13. package/bin/datatypes/index.d.ts +43 -0
  14. package/bin/datatypes/index.js +120 -0
  15. package/bin/error.d.ts +7 -0
  16. package/bin/error.js +17 -0
  17. package/bin/functions.d.ts +26 -0
  18. package/bin/functions.js +208 -0
  19. package/bin/groupby.d.ts +212 -0
  20. package/bin/groupby.js +156 -0
  21. package/bin/html.d.ts +4 -0
  22. package/bin/html.js +18 -0
  23. package/bin/index.d.ts +256 -0
  24. package/bin/index.js +267 -0
  25. package/bin/internals/construction.d.ts +7 -0
  26. package/bin/internals/construction.js +256 -0
  27. package/bin/internals/polars_internal.d.ts +2 -0
  28. package/bin/internals/polars_internal.js +7 -0
  29. package/bin/io.d.ts +433 -0
  30. package/bin/io.js +344 -0
  31. package/bin/lazy/dataframe.d.ts +785 -0
  32. package/bin/lazy/dataframe.js +427 -0
  33. package/bin/lazy/expr/datetime.d.ts +8 -0
  34. package/bin/lazy/expr/datetime.js +27 -0
  35. package/bin/lazy/expr/index.d.ts +1152 -0
  36. package/bin/lazy/expr/index.js +632 -0
  37. package/bin/lazy/expr/list.d.ts +8 -0
  38. package/bin/lazy/expr/list.js +115 -0
  39. package/bin/lazy/expr/string.d.ts +534 -0
  40. package/bin/lazy/expr/string.js +131 -0
  41. package/bin/lazy/expr/struct.d.ts +126 -0
  42. package/bin/lazy/expr/struct.js +26 -0
  43. package/bin/lazy/functions.d.ts +612 -0
  44. package/bin/lazy/functions.js +687 -0
  45. package/bin/lazy/groupby.d.ts +29 -0
  46. package/bin/lazy/groupby.js +30 -0
  47. package/bin/lazy/index.d.ts +4 -0
  48. package/bin/lazy/index.js +20 -0
  49. package/bin/lazy/whenthen.d.ts +67 -0
  50. package/bin/lazy/whenthen.js +81 -0
  51. package/bin/native-polars.d.ts +2 -0
  52. package/bin/native-polars.js +267 -0
  53. package/bin/series/datetime.d.ts +8 -0
  54. package/bin/series/datetime.js +34 -0
  55. package/bin/series/index.d.ts +1135 -0
  56. package/bin/series/index.js +700 -0
  57. package/bin/series/list.d.ts +8 -0
  58. package/bin/series/list.js +87 -0
  59. package/bin/series/string.d.ts +300 -0
  60. package/bin/series/string.js +125 -0
  61. package/bin/series/struct.d.ts +36 -0
  62. package/bin/series/struct.js +35 -0
  63. package/bin/shared_traits.d.ts +1458 -0
  64. package/bin/shared_traits.js +2 -0
  65. package/bin/sql.d.ts +244 -0
  66. package/bin/sql.js +63 -0
  67. package/bin/types.d.ts +287 -0
  68. package/bin/types.js +2 -0
  69. package/bin/utils.d.ts +38 -0
  70. package/bin/utils.js +69 -0
  71. package/package.json +45 -0
@@ -0,0 +1,632 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.exprToLitOrExpr = exports.Expr = exports._Expr = void 0;
40
+ const dt = __importStar(require("./datetime"));
41
+ const lst = __importStar(require("./list"));
42
+ const str = __importStar(require("./string"));
43
+ const struct = __importStar(require("./struct"));
44
+ const types_1 = require("node:util/types");
45
+ const polars_internal_1 = __importDefault(require("../../internals/polars_internal"));
46
+ const series_1 = require("../../series");
47
+ const utils_1 = require("../../utils");
48
+ /** @ignore */
49
+ const _Expr = (_expr) => {
50
+ const unwrap = (method, ...args) => {
51
+ return _expr[method](...args);
52
+ };
53
+ const wrap = (method, ...args) => {
54
+ return (0, exports._Expr)(unwrap(method, ...args));
55
+ };
56
+ const wrapExprArg = (method, lit = false) => (other) => {
57
+ const expr = (0, exports.exprToLitOrExpr)(other, lit).inner();
58
+ return wrap(method, expr);
59
+ };
60
+ const rolling = (method) => (opts, weights, minPeriods, center) => {
61
+ const windowSize = opts?.["windowSize"] ?? (typeof opts === "number" ? opts : null);
62
+ if (windowSize === null) {
63
+ throw new Error("window size is required");
64
+ }
65
+ const callOpts = {
66
+ windowSize: windowSize,
67
+ weights: opts?.["weights"] ?? weights,
68
+ minPeriods: opts?.["minPeriods"] ?? minPeriods ?? windowSize,
69
+ center: opts?.["center"] ?? center ?? false,
70
+ };
71
+ return wrap(method, callOpts);
72
+ };
73
+ return {
74
+ _expr,
75
+ [Symbol.toStringTag]() {
76
+ return "Expr";
77
+ },
78
+ [utils_1.INSPECT_SYMBOL]() {
79
+ return _expr.toString();
80
+ },
81
+ serialize(format) {
82
+ return _expr.serialize(format);
83
+ },
84
+ toString() {
85
+ return _expr.toString();
86
+ },
87
+ toJSON(...args) {
88
+ // this is passed by `JSON.stringify` when calling `toJSON()`
89
+ if (args[0] === "") {
90
+ return _expr.toJs();
91
+ }
92
+ return _expr.serialize("json").toString();
93
+ },
94
+ get str() {
95
+ return str.ExprStringFunctions(_expr);
96
+ },
97
+ get lst() {
98
+ return lst.ExprListFunctions(_expr);
99
+ },
100
+ get date() {
101
+ return dt.ExprDateTimeFunctions(_expr);
102
+ },
103
+ get dt() {
104
+ return dt.ExprDateTimeFunctions(_expr);
105
+ },
106
+ get struct() {
107
+ return struct.ExprStructFunctions(_expr);
108
+ },
109
+ abs() {
110
+ return (0, exports._Expr)(_expr.abs());
111
+ },
112
+ aggGroups() {
113
+ return (0, exports._Expr)(_expr.aggGroups());
114
+ },
115
+ alias(name) {
116
+ return (0, exports._Expr)(_expr.alias(name));
117
+ },
118
+ inner() {
119
+ return _expr;
120
+ },
121
+ and(other) {
122
+ const expr = (0, exports.exprToLitOrExpr)(other, false).inner();
123
+ return (0, exports._Expr)(_expr.and(expr));
124
+ },
125
+ arccos() {
126
+ return (0, exports._Expr)(_expr.arccos());
127
+ },
128
+ arccosh() {
129
+ return (0, exports._Expr)(_expr.arccosh());
130
+ },
131
+ arcsin() {
132
+ return (0, exports._Expr)(_expr.arcsin());
133
+ },
134
+ arcsinh() {
135
+ return (0, exports._Expr)(_expr.arcsinh());
136
+ },
137
+ arctan() {
138
+ return (0, exports._Expr)(_expr.arctan());
139
+ },
140
+ arctanh() {
141
+ return (0, exports._Expr)(_expr.arctanh());
142
+ },
143
+ argMax() {
144
+ return (0, exports._Expr)(_expr.argMax());
145
+ },
146
+ argMin() {
147
+ return (0, exports._Expr)(_expr.argMin());
148
+ },
149
+ argSort(descending = false, nullsLast = false) {
150
+ descending = descending?.descending ?? descending;
151
+ nullsLast = descending?.nullsLast ?? nullsLast;
152
+ return (0, exports._Expr)(_expr.argSort(descending, nullsLast));
153
+ },
154
+ argUnique() {
155
+ return (0, exports._Expr)(_expr.argUnique());
156
+ },
157
+ as(name) {
158
+ return (0, exports._Expr)(_expr.alias(name));
159
+ },
160
+ backwardFill() {
161
+ return (0, exports._Expr)(_expr.backwardFill());
162
+ },
163
+ cast(dtype, strict = false) {
164
+ return (0, exports._Expr)(_expr.cast(dtype, strict));
165
+ },
166
+ ceil() {
167
+ return (0, exports._Expr)(_expr.ceil());
168
+ },
169
+ clip(arg, max) {
170
+ if (typeof arg === "number") {
171
+ return (0, exports._Expr)(_expr.clip((0, exports.exprToLitOrExpr)(arg)._expr, (0, exports.exprToLitOrExpr)(max)._expr));
172
+ }
173
+ return (0, exports._Expr)(_expr.clip((0, exports.exprToLitOrExpr)(arg.min)._expr, (0, exports.exprToLitOrExpr)(arg.max)._expr));
174
+ },
175
+ cos() {
176
+ return (0, exports._Expr)(_expr.cos());
177
+ },
178
+ cosh() {
179
+ return (0, exports._Expr)(_expr.cosh());
180
+ },
181
+ cot() {
182
+ return (0, exports._Expr)(_expr.cot());
183
+ },
184
+ count() {
185
+ return (0, exports._Expr)(_expr.count());
186
+ },
187
+ cumCount(reverse = false) {
188
+ reverse = reverse?.reverse ?? reverse;
189
+ return (0, exports._Expr)(_expr.cumCount(reverse?.reverse ?? reverse));
190
+ },
191
+ cumMax(reverse = false) {
192
+ reverse = reverse?.reverse ?? reverse;
193
+ return (0, exports._Expr)(_expr.cumMax(reverse));
194
+ },
195
+ cumMin(reverse = false) {
196
+ reverse = reverse?.reverse ?? reverse;
197
+ return (0, exports._Expr)(_expr.cumMin(reverse));
198
+ },
199
+ cumProd(reverse = false) {
200
+ reverse = reverse?.reverse ?? reverse;
201
+ return (0, exports._Expr)(_expr.cumProd(reverse));
202
+ },
203
+ cumSum(reverse = false) {
204
+ reverse = reverse?.reverse ?? reverse;
205
+ return (0, exports._Expr)(_expr.cumSum(reverse));
206
+ },
207
+ diff(n, nullBehavior = "ignore") {
208
+ if (typeof n === "number") {
209
+ return (0, exports._Expr)(_expr.diff((0, exports.exprToLitOrExpr)(n, false), nullBehavior));
210
+ }
211
+ return (0, exports._Expr)(_expr.diff((0, exports.exprToLitOrExpr)(n.n, false), n.nullBehavior));
212
+ },
213
+ dot(other) {
214
+ const expr = (0, exports.exprToLitOrExpr)(other, false).inner();
215
+ return (0, exports._Expr)(_expr.dot(expr));
216
+ },
217
+ ewmMean(opts, adjust, minPeriods, bias, ignoreNulls) {
218
+ if (opts) {
219
+ if (typeof opts === "number") {
220
+ return wrap("ewmMean", opts, adjust ?? true, minPeriods ?? 1, bias ?? false, ignoreNulls ?? true);
221
+ }
222
+ return wrap("ewmMean", opts.alpha ?? 0.5, opts.adjust ?? true, opts.minPeriods ?? 1, opts.bias ?? false, opts.ignoreNulls ?? true);
223
+ }
224
+ return wrap("ewmMean", 0.5, true, 1, false, true);
225
+ },
226
+ ewmStd(opts, adjust, minPeriods, bias, ignoreNulls) {
227
+ if (opts) {
228
+ if (typeof opts === "number") {
229
+ return wrap("ewmStd", opts, adjust ?? true, minPeriods ?? 1, bias ?? false, ignoreNulls ?? true);
230
+ }
231
+ return wrap("ewmStd", opts.alpha ?? 0.5, opts.adjust ?? true, opts.minPeriods ?? 1, opts.bias ?? false, opts.ignoreNulls ?? true);
232
+ }
233
+ return wrap("ewmStd", 0.5, true, 1, false, true);
234
+ },
235
+ ewmVar(opts, adjust, minPeriods, bias, ignoreNulls) {
236
+ if (opts) {
237
+ if (typeof opts === "number") {
238
+ return wrap("ewmVar", opts, adjust ?? true, minPeriods ?? 1, bias ?? false, ignoreNulls ?? true);
239
+ }
240
+ return wrap("ewmVar", opts.alpha ?? 0.5, opts.adjust ?? true, opts.minPeriods ?? 1, opts.bias ?? false, opts.ignoreNulls ?? true);
241
+ }
242
+ return wrap("ewmVar", 0.5, true, 1, false, true);
243
+ },
244
+ exclude(...columns) {
245
+ return (0, exports._Expr)(_expr.exclude(columns.flat(2)));
246
+ },
247
+ explode() {
248
+ return (0, exports._Expr)(_expr.explode());
249
+ },
250
+ exp() {
251
+ return (0, exports._Expr)(_expr.exp());
252
+ },
253
+ extendConstant(o, n) {
254
+ if (n !== null && typeof n === "number") {
255
+ return (0, exports._Expr)(_expr.extendConstant(o, n));
256
+ }
257
+ return (0, exports._Expr)(_expr.extendConstant(o.value, o.n));
258
+ },
259
+ fillNan(other) {
260
+ const expr = (0, exports.exprToLitOrExpr)(other, true).inner();
261
+ return (0, exports._Expr)(_expr.fillNan(expr));
262
+ },
263
+ fillNull(fillValue) {
264
+ if (["backward", "forward", "mean", "min", "max", "zero", "one"].includes(fillValue)) {
265
+ return (0, exports._Expr)(_expr.fillNullWithStrategy(fillValue));
266
+ }
267
+ const expr = (0, exports.exprToLitOrExpr)(fillValue).inner();
268
+ return (0, exports._Expr)(_expr.fillNull(expr));
269
+ },
270
+ filter(predicate) {
271
+ const expr = (0, exports.exprToLitOrExpr)(predicate).inner();
272
+ return (0, exports._Expr)(_expr.filter(expr));
273
+ },
274
+ first() {
275
+ return (0, exports._Expr)(_expr.first());
276
+ },
277
+ flatten() {
278
+ return (0, exports._Expr)(_expr.explode());
279
+ },
280
+ floor() {
281
+ return (0, exports._Expr)(_expr.floor());
282
+ },
283
+ forwardFill() {
284
+ return (0, exports._Expr)(_expr.forwardFill());
285
+ },
286
+ gather(indices) {
287
+ if (Array.isArray(indices)) {
288
+ indices = polars_internal_1.default.litSeries((0, series_1.Series)("", indices, polars_internal_1.default.Int64).inner());
289
+ }
290
+ else {
291
+ indices = indices.inner();
292
+ }
293
+ return wrap("gather", indices);
294
+ },
295
+ gatherEvery(n, offset = 0) {
296
+ return (0, exports._Expr)(_expr.gatherEvery(n, offset));
297
+ },
298
+ hash(obj = 0, k1 = 1, k2 = 2, k3 = 3) {
299
+ if (typeof obj === "number" || typeof obj === "bigint") {
300
+ return wrap("hash", BigInt(obj), BigInt(k1), BigInt(k2), BigInt(k3));
301
+ }
302
+ const o = { k0: obj, k1: k1, k2: k2, k3: k3, ...obj };
303
+ return wrap("hash", BigInt(o.k0), BigInt(o.k1), BigInt(o.k2), BigInt(o.k3));
304
+ },
305
+ head(length) {
306
+ if (typeof length === "number") {
307
+ return wrap("head", length);
308
+ }
309
+ return wrap("head", length.length);
310
+ },
311
+ implode() {
312
+ return (0, exports._Expr)(_expr.implode());
313
+ },
314
+ interpolate(method = "linear") {
315
+ return (0, exports._Expr)(_expr.interpolate(method));
316
+ },
317
+ isDuplicated() {
318
+ return (0, exports._Expr)(_expr.isDuplicated());
319
+ },
320
+ isFinite() {
321
+ return (0, exports._Expr)(_expr.isFinite());
322
+ },
323
+ isInfinite() {
324
+ return (0, exports._Expr)(_expr.isInfinite());
325
+ },
326
+ isFirstDistinct() {
327
+ return (0, exports._Expr)(_expr.isFirstDistinct());
328
+ },
329
+ isNan() {
330
+ return (0, exports._Expr)(_expr.isNan());
331
+ },
332
+ isNotNan() {
333
+ return (0, exports._Expr)(_expr.isNotNan());
334
+ },
335
+ isNotNull() {
336
+ return (0, exports._Expr)(_expr.isNotNull());
337
+ },
338
+ isNull() {
339
+ return (0, exports._Expr)(_expr.isNull());
340
+ },
341
+ isUnique() {
342
+ return (0, exports._Expr)(_expr.isUnique());
343
+ },
344
+ isIn(other, nullsEquals = false) {
345
+ if (Array.isArray(other)) {
346
+ other = polars_internal_1.default.lit((0, series_1.Series)(other).inner());
347
+ }
348
+ else {
349
+ other = (0, exports.exprToLitOrExpr)(other, false).inner();
350
+ }
351
+ return wrap("isIn", other, nullsEquals);
352
+ },
353
+ keepName() {
354
+ return (0, exports._Expr)(_expr.keepName());
355
+ },
356
+ kurtosis(obj, bias = true) {
357
+ const fisher = obj?.["fisher"] ?? (typeof obj === "boolean" ? obj : true);
358
+ bias = obj?.["bias"] ?? bias;
359
+ return (0, exports._Expr)(_expr.kurtosis(fisher, bias));
360
+ },
361
+ last() {
362
+ return (0, exports._Expr)(_expr.last());
363
+ },
364
+ list() {
365
+ return (0, exports._Expr)(_expr.list());
366
+ },
367
+ log1p() {
368
+ return (0, exports._Expr)(_expr.log1p());
369
+ },
370
+ log(base) {
371
+ return (0, exports._Expr)(_expr.log(base ?? Math.E));
372
+ },
373
+ lowerBound() {
374
+ return (0, exports._Expr)(_expr.lowerBound());
375
+ },
376
+ peakMax() {
377
+ return (0, exports._Expr)(_expr.peakMax());
378
+ },
379
+ peakMin() {
380
+ return (0, exports._Expr)(_expr.peakMin());
381
+ },
382
+ max() {
383
+ return (0, exports._Expr)(_expr.max());
384
+ },
385
+ mean() {
386
+ return (0, exports._Expr)(_expr.mean());
387
+ },
388
+ median() {
389
+ return (0, exports._Expr)(_expr.median());
390
+ },
391
+ min() {
392
+ return (0, exports._Expr)(_expr.min());
393
+ },
394
+ mode() {
395
+ return (0, exports._Expr)(_expr.mode());
396
+ },
397
+ not() {
398
+ return (0, exports._Expr)(_expr.not());
399
+ },
400
+ nUnique() {
401
+ return (0, exports._Expr)(_expr.nUnique());
402
+ },
403
+ or(other) {
404
+ const expr = (0, exports.exprToLitOrExpr)(other).inner();
405
+ return (0, exports._Expr)(_expr.or(expr));
406
+ },
407
+ over(...exprs) {
408
+ const partitionBy = (0, utils_1.selectionToExprList)(exprs, false);
409
+ return wrap("over", partitionBy);
410
+ },
411
+ pow(exponent) {
412
+ return (0, exports._Expr)(_expr.pow(exponent?.exponent ?? exponent));
413
+ },
414
+ prefix(prefix) {
415
+ return (0, exports._Expr)(_expr.prefix(prefix));
416
+ },
417
+ quantile(quantile, interpolation = "nearest") {
418
+ if (exports.Expr.isExpr(quantile)) {
419
+ quantile = quantile._expr;
420
+ }
421
+ else {
422
+ quantile = polars_internal_1.default.lit(quantile);
423
+ }
424
+ return (0, exports._Expr)(_expr.quantile(quantile, interpolation));
425
+ },
426
+ rank(method = "average", descending = false) {
427
+ return (0, exports._Expr)(_expr.rank(method?.method ?? method, method?.descending ?? descending));
428
+ },
429
+ reinterpret(signed = true) {
430
+ signed = signed?.signed ?? signed;
431
+ return (0, exports._Expr)(_expr.reinterpret(signed));
432
+ },
433
+ repeatBy(expr) {
434
+ const e = (0, exports.exprToLitOrExpr)(expr, false)._expr;
435
+ return (0, exports._Expr)(_expr.repeatBy(e));
436
+ },
437
+ replace(old, newValue) {
438
+ let oldIn = old;
439
+ let newIn = newValue;
440
+ if (old && typeof old === "object" && !Array.isArray(old)) {
441
+ oldIn = Object.keys(old["old"]);
442
+ newIn = Object.values(old["old"]);
443
+ }
444
+ return (0, exports._Expr)(_expr.replace((0, exports.exprToLitOrExpr)(oldIn)._expr, (0, exports.exprToLitOrExpr)(newIn)._expr));
445
+ },
446
+ replaceStrict(old, newValue, defaultValue, returnDtype) {
447
+ let oldIn = old;
448
+ let newIn = newValue;
449
+ let defIn = defaultValue;
450
+ if (old && typeof old === "object" && !Array.isArray(old)) {
451
+ oldIn = Object.keys(old["old"]);
452
+ newIn = Object.values(old["old"]);
453
+ defIn = old["default_"];
454
+ }
455
+ return (0, exports._Expr)(_expr.replaceStrict((0, exports.exprToLitOrExpr)(oldIn)._expr, (0, exports.exprToLitOrExpr)(newIn)._expr, defIn ? (0, exports.exprToLitOrExpr)(defIn)._expr : undefined, returnDtype));
456
+ },
457
+ reverse() {
458
+ return (0, exports._Expr)(_expr.reverse());
459
+ },
460
+ rollingMax: rolling("rollingMax"),
461
+ rollingMean: rolling("rollingMean"),
462
+ rollingMin: rolling("rollingMin"),
463
+ rollingSum: rolling("rollingSum"),
464
+ rollingStd: rolling("rollingStd"),
465
+ rollingVar: rolling("rollingVar"),
466
+ rollingMedian: rolling("rollingMedian"),
467
+ rollingQuantile(val, _interpolation, windowSize, weights, minPeriods, center, by, closedWindow, warnIfUnsorted) {
468
+ if (typeof val === "number") {
469
+ return wrap("rollingQuantile", {
470
+ windowSize: `${windowSize}i`,
471
+ weights,
472
+ minPeriods,
473
+ center,
474
+ });
475
+ }
476
+ windowSize =
477
+ val?.["windowSize"] ?? (typeof val === "number" ? val : null);
478
+ if (windowSize === null) {
479
+ throw new Error("window size is required");
480
+ }
481
+ return wrap("rollingQuantile", val.quantile, val.interpolation ?? "nearest", windowSize, val?.["weights"] ?? weights ?? null, val?.["minPeriods"] ?? minPeriods ?? windowSize, val?.["center"] ?? center ?? false, val?.["by"] ?? by, closedWindow, val?.["warnIfUnsorted"] ?? warnIfUnsorted ?? true);
482
+ },
483
+ rollingSkew(val, bias = true) {
484
+ if (typeof val === "number") {
485
+ return wrap("rollingSkew", val, bias);
486
+ }
487
+ return wrap("rollingSkew", val.windowSize, val.bias ?? bias);
488
+ },
489
+ round(decimals, mode) {
490
+ return (0, exports._Expr)(_expr.round(decimals?.decimals ?? decimals, decimals?.mode ?? mode ?? "halftoeven"));
491
+ },
492
+ sample(opts, frac, withReplacement = false, seed) {
493
+ if (opts?.n !== undefined || opts?.frac !== undefined) {
494
+ return this.sample(opts.n, opts.frac, opts.withReplacement, opts.seed);
495
+ }
496
+ if (typeof opts === "number") {
497
+ return wrap("sampleN", (0, exports.exprToLitOrExpr)(opts), withReplacement, false, seed);
498
+ }
499
+ if (typeof frac === "number") {
500
+ return wrap("sampleFrac", (0, exports.exprToLitOrExpr)(frac), withReplacement, false, seed);
501
+ }
502
+ throw new TypeError("must specify either 'frac' or 'n'");
503
+ },
504
+ shift(periods) {
505
+ return (0, exports._Expr)(_expr.shift((0, exports.exprToLitOrExpr)(periods)._expr));
506
+ },
507
+ shiftAndFill(optOrPeriods, fillValue) {
508
+ if (typeof optOrPeriods === "number") {
509
+ return wrap("shiftAndFill", optOrPeriods, fillValue);
510
+ }
511
+ return wrap("shiftAndFill", optOrPeriods.periods, optOrPeriods.fillValue);
512
+ },
513
+ skew(bias) {
514
+ return wrap("skew", bias?.bias ?? bias ?? true);
515
+ },
516
+ sin() {
517
+ return (0, exports._Expr)(_expr.sin());
518
+ },
519
+ sinh() {
520
+ return (0, exports._Expr)(_expr.sinh());
521
+ },
522
+ slice(arg, len) {
523
+ if (typeof arg === "number") {
524
+ return wrap("slice", polars_internal_1.default.lit(arg), polars_internal_1.default.lit(len));
525
+ }
526
+ return wrap("slice", polars_internal_1.default.lit(arg.offset), polars_internal_1.default.lit(arg.length));
527
+ },
528
+ sort(descending = false, nullsLast = false, maintainOrder = false) {
529
+ if (typeof descending === "boolean") {
530
+ return wrap("sortWith", descending, nullsLast, false, maintainOrder);
531
+ }
532
+ return wrap("sortWith", descending?.descending ?? false, descending?.nullsLast ?? nullsLast, false, descending?.maintainOrder ?? maintainOrder);
533
+ },
534
+ sortBy(arg, descending = false) {
535
+ if (arg?.by !== undefined) {
536
+ return this.sortBy(arg.by, arg.descending ?? false);
537
+ }
538
+ descending = Array.isArray(descending)
539
+ ? descending.flat()
540
+ : [descending];
541
+ const by = (0, utils_1.selectionToExprList)(arg, false);
542
+ return wrap("sortBy", by, descending);
543
+ },
544
+ std() {
545
+ return (0, exports._Expr)(_expr.std());
546
+ },
547
+ suffix(suffix) {
548
+ return (0, exports._Expr)(_expr.suffix(suffix));
549
+ },
550
+ sum() {
551
+ return (0, exports._Expr)(_expr.sum());
552
+ },
553
+ tail(length) {
554
+ return (0, exports._Expr)(_expr.tail(length));
555
+ },
556
+ tan() {
557
+ return (0, exports._Expr)(_expr.tan());
558
+ },
559
+ tanh() {
560
+ return (0, exports._Expr)(_expr.tanh());
561
+ },
562
+ unique(opt) {
563
+ if (opt || opt?.maintainOrder) {
564
+ return wrap("uniqueStable");
565
+ }
566
+ return wrap("unique");
567
+ },
568
+ upperBound() {
569
+ return (0, exports._Expr)(_expr.upperBound());
570
+ },
571
+ where(expr) {
572
+ return this.filter(expr);
573
+ },
574
+ var() {
575
+ return (0, exports._Expr)(_expr.var());
576
+ },
577
+ add: wrapExprArg("add"),
578
+ sub: wrapExprArg("sub"),
579
+ div: wrapExprArg("div"),
580
+ mul: wrapExprArg("mul"),
581
+ rem: wrapExprArg("rem"),
582
+ plus: wrapExprArg("add"),
583
+ minus: wrapExprArg("sub"),
584
+ divideBy: wrapExprArg("div"),
585
+ multiplyBy: wrapExprArg("mul"),
586
+ modulo: wrapExprArg("rem"),
587
+ eq: wrapExprArg("eq"),
588
+ equals: wrapExprArg("eq"),
589
+ gtEq: wrapExprArg("gtEq"),
590
+ greaterThanEquals: wrapExprArg("gtEq"),
591
+ gt: wrapExprArg("gt"),
592
+ greaterThan: wrapExprArg("gt"),
593
+ ltEq: wrapExprArg("ltEq"),
594
+ lessThanEquals: wrapExprArg("ltEq"),
595
+ lt: wrapExprArg("lt"),
596
+ lessThan: wrapExprArg("lt"),
597
+ neq: wrapExprArg("neq"),
598
+ notEquals: wrapExprArg("neq"),
599
+ };
600
+ };
601
+ exports._Expr = _Expr;
602
+ const isExpr = (anyVal) => {
603
+ try {
604
+ return anyVal?.[Symbol.toStringTag]?.() === "Expr";
605
+ }
606
+ catch (_err) {
607
+ return false;
608
+ }
609
+ };
610
+ const deserialize = (buf, format) => {
611
+ return (0, exports._Expr)(polars_internal_1.default.JsExpr.deserialize(buf, format));
612
+ };
613
+ exports.Expr = Object.assign(exports._Expr, {
614
+ isExpr,
615
+ deserialize,
616
+ });
617
+ const exprToLitOrExpr = (expr, stringToLit = true) => {
618
+ if ((0, types_1.isRegExp)(expr)) {
619
+ return (0, exports._Expr)(polars_internal_1.default.lit((0, utils_1.regexToString)(expr)));
620
+ }
621
+ if (typeof expr === "string" && !stringToLit) {
622
+ return (0, exports._Expr)(polars_internal_1.default.col(expr));
623
+ }
624
+ if (exports.Expr.isExpr(expr)) {
625
+ return expr;
626
+ }
627
+ if (series_1.Series.isSeries(expr)) {
628
+ return (0, exports._Expr)(polars_internal_1.default.litSeries(expr._s));
629
+ }
630
+ return (0, exports._Expr)(polars_internal_1.default.lit(expr));
631
+ };
632
+ exports.exprToLitOrExpr = exprToLitOrExpr;
@@ -0,0 +1,8 @@
1
+ import type { ListFunctions } from "../../shared_traits";
2
+ import { Expr } from "../expr";
3
+ /**
4
+ * List functions for Lazy dataframes
5
+ */
6
+ export interface ExprList extends ListFunctions<Expr> {
7
+ }
8
+ export declare const ExprListFunctions: (_expr: any) => ExprList;