@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,687 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.col = col;
7
+ exports.cols = cols;
8
+ exports.nth = nth;
9
+ exports.lit = lit;
10
+ exports.intRange = intRange;
11
+ exports.intRanges = intRanges;
12
+ exports.all = all;
13
+ exports.argSortBy = argSortBy;
14
+ exports.avg = avg;
15
+ exports.concatList = concatList;
16
+ exports.concatString = concatString;
17
+ exports.count = count;
18
+ exports.cov = cov;
19
+ exports.exclude = exclude;
20
+ exports.first = first;
21
+ exports.format = format;
22
+ exports.groups = groups;
23
+ exports.head = head;
24
+ exports.len = len;
25
+ exports.last = last;
26
+ exports.mean = mean;
27
+ exports.median = median;
28
+ exports.nUnique = nUnique;
29
+ exports.pearsonCorr = pearsonCorr;
30
+ exports.quantile = quantile;
31
+ exports.select = select;
32
+ exports.spearmanRankCorr = spearmanRankCorr;
33
+ exports.tail = tail;
34
+ exports.list = list;
35
+ exports.struct = struct;
36
+ exports.element = element;
37
+ exports.allHorizontal = allHorizontal;
38
+ exports.anyHorizontal = anyHorizontal;
39
+ exports.maxHorizontal = maxHorizontal;
40
+ exports.minHorizontal = minHorizontal;
41
+ exports.sumHorizontal = sumHorizontal;
42
+ const dataframe_1 = require("../dataframe");
43
+ const datatypes_1 = require("../datatypes");
44
+ const polars_internal_1 = __importDefault(require("../internals/polars_internal"));
45
+ const series_1 = require("../series");
46
+ const utils_1 = require("../utils");
47
+ const expr_1 = require("./expr");
48
+ /**
49
+ * __A column in a DataFrame.__
50
+ * Can be used to select:
51
+ * * a single column by name
52
+ * * all columns by using a wildcard `"*"`
53
+ * * column by regular expression if the regex starts with `^` and ends with `$`
54
+ * @param col
55
+ * @example
56
+ * ```
57
+ * > df = pl.DataFrame({
58
+ * > "ham": [1, 2, 3],
59
+ * > "hamburger": [11, 22, 33],
60
+ * > "foo": [3, 2, 1]})
61
+ * > df.select(col("foo"))
62
+ * shape: (3, 1)
63
+ * ╭─────╮
64
+ * │ foo │
65
+ * │ --- │
66
+ * │ i64 │
67
+ * ╞═════╡
68
+ * │ 3 │
69
+ * ├╌╌╌╌╌┤
70
+ * │ 2 │
71
+ * ├╌╌╌╌╌┤
72
+ * │ 1 │
73
+ * ╰─────╯
74
+ * > df.select(col("*"))
75
+ * shape: (3, 3)
76
+ * ╭─────┬───────────┬─────╮
77
+ * │ ham ┆ hamburger ┆ foo │
78
+ * │ --- ┆ --- ┆ --- │
79
+ * │ i64 ┆ i64 ┆ i64 │
80
+ * ╞═════╪═══════════╪═════╡
81
+ * │ 1 ┆ 11 ┆ 3 │
82
+ * ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
83
+ * │ 2 ┆ 22 ┆ 2 │
84
+ * ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
85
+ * │ 3 ┆ 33 ┆ 1 │
86
+ * ╰─────┴───────────┴─────╯
87
+ * > df.select(col("^ham.*$"))
88
+ * shape: (3, 2)
89
+ * ╭─────┬───────────╮
90
+ * │ ham ┆ hamburger │
91
+ * │ --- ┆ --- │
92
+ * │ i64 ┆ i64 │
93
+ * ╞═════╪═══════════╡
94
+ * │ 1 ┆ 11 │
95
+ * ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
96
+ * │ 2 ┆ 22 │
97
+ * ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
98
+ * │ 3 ┆ 33 │
99
+ * ╰─────┴───────────╯
100
+ * > df.select(col("*").exclude("ham"))
101
+ * shape: (3, 2)
102
+ * ╭───────────┬─────╮
103
+ * │ hamburger ┆ foo │
104
+ * │ --- ┆ --- │
105
+ * │ i64 ┆ i64 │
106
+ * ╞═══════════╪═════╡
107
+ * │ 11 ┆ 3 │
108
+ * ├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
109
+ * │ 22 ┆ 2 │
110
+ * ├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
111
+ * │ 33 ┆ 1 │
112
+ * ╰───────────┴─────╯
113
+ * > df.select(col(["hamburger", "foo"])
114
+ * shape: (3, 2)
115
+ * ╭───────────┬─────╮
116
+ * │ hamburger ┆ foo │
117
+ * │ --- ┆ --- │
118
+ * │ i64 ┆ i64 │
119
+ * ╞═══════════╪═════╡
120
+ * │ 11 ┆ 3 │
121
+ * ├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
122
+ * │ 22 ┆ 2 │
123
+ * ├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
124
+ * │ 33 ┆ 1 │
125
+ * ╰───────────┴─────╯
126
+ * > df.select(col(pl.Series(["hamburger", "foo"]))
127
+ * shape: (3, 2)
128
+ * ╭───────────┬─────╮
129
+ * │ hamburger ┆ foo │
130
+ * │ --- ┆ --- │
131
+ * │ i64 ┆ i64 │
132
+ * ╞═══════════╪═════╡
133
+ * │ 11 ┆ 3 │
134
+ * ├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
135
+ * │ 22 ┆ 2 │
136
+ * ├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┤
137
+ * │ 33 ┆ 1 │
138
+ * ╰───────────┴─────╯
139
+ * ```
140
+ */
141
+ function col(col) {
142
+ if (series_1.Series.isSeries(col)) {
143
+ col = col.toArray();
144
+ }
145
+ if (Array.isArray(col)) {
146
+ return (0, expr_1._Expr)(polars_internal_1.default.cols(col));
147
+ }
148
+ if (typeof col === "object" && Object.values(col)[0] === "DataType") {
149
+ return (0, expr_1._Expr)(polars_internal_1.default.dtypeCols([col]));
150
+ }
151
+ return (0, expr_1._Expr)(polars_internal_1.default.col(col));
152
+ }
153
+ function cols(...cols) {
154
+ return col(cols.flat());
155
+ }
156
+ /**
157
+ * Select nth column index in a DataFrame.
158
+ * @param n - Column index to select, starting at 0.
159
+ * @example
160
+ * ```
161
+ * > df = pl.DataFrame({
162
+ * > "ham": [1, 2, 3],
163
+ * > "hamburger": [11, 22, 33],
164
+ * > "foo": [3, 2, 1]})
165
+ * > df.select(nth(2))
166
+ * shape: (3, 1)
167
+ * ╭─────╮
168
+ * │ foo │
169
+ * │ --- │
170
+ * │ i64 │
171
+ * ╞═════╡
172
+ * │ 3 │
173
+ * ├╌╌╌╌╌┤
174
+ * │ 2 │
175
+ * ├╌╌╌╌╌┤
176
+ * │ 1 │
177
+ * ╰─────╯
178
+ * ```
179
+ */
180
+ function nth(n) {
181
+ return (0, expr_1._Expr)(polars_internal_1.default.nth(n));
182
+ }
183
+ function lit(value) {
184
+ if (Array.isArray(value)) {
185
+ value = (0, series_1.Series)(value);
186
+ }
187
+ if (series_1.Series.isSeries(value)) {
188
+ return (0, expr_1._Expr)(polars_internal_1.default.lit(value.inner()));
189
+ }
190
+ return (0, expr_1._Expr)(polars_internal_1.default.lit(value));
191
+ }
192
+ function intRange(opts, end, step = 1, dtype, eager) {
193
+ if (typeof opts?.start === "number") {
194
+ return intRange(opts.start, opts.end, opts.step, opts.dtype, opts.eager);
195
+ }
196
+ // if expression like pl.len() passed
197
+ if (end === undefined || end === null) {
198
+ end = opts;
199
+ opts = 0;
200
+ }
201
+ const start = (0, expr_1.exprToLitOrExpr)(opts, false);
202
+ end = (0, expr_1.exprToLitOrExpr)(end, false);
203
+ if (eager) {
204
+ const df = (0, dataframe_1.DataFrame)({ a: [1] });
205
+ return df
206
+ .select(intRange(start, end, step).alias("intRange"))
207
+ .getColumn("intRange");
208
+ }
209
+ return (0, expr_1._Expr)(polars_internal_1.default.intRange(start, end, step, dtype || datatypes_1.DataType.Int64));
210
+ }
211
+ function intRanges(start, end, step = 1, dtype = datatypes_1.DataType.Int64, eager) {
212
+ start = (0, expr_1.exprToLitOrExpr)(start, false);
213
+ end = (0, expr_1.exprToLitOrExpr)(end, false);
214
+ step = (0, expr_1.exprToLitOrExpr)(step, false);
215
+ if (eager) {
216
+ const df = (0, dataframe_1.DataFrame)({ a: [1] });
217
+ return df
218
+ .select(intRanges(start, end, step, dtype).alias("intRanges"))
219
+ .getColumn("intRanges");
220
+ }
221
+ return (0, expr_1._Expr)(polars_internal_1.default.intRanges(start, end, step, dtype));
222
+ }
223
+ /** Alias for `pl.col("*")` */
224
+ function all() {
225
+ return col("*");
226
+ }
227
+ /**
228
+ * Return the row indices that would sort the columns.
229
+ * @param exprs Column(s) to arg sort by. Accepts expression input.
230
+ * @param descending Sort in descending order. When sorting by multiple columns, can be specified per column by passing a sequence of booleans.
231
+ * @example
232
+ * ```
233
+ * const df = pl.DataFrame({"a": [0, 1, 1, 0], "b": [3, 2, 3, 2],});
234
+ * df.select(pl.argSortBy(pl.col("a")));
235
+ * shape: (4, 1)
236
+ * ┌─────┐
237
+ * │ a │
238
+ * │ --- │
239
+ * │ u32 │
240
+ * ╞═════╡
241
+ * │ 0 │
242
+ * │ 3 │
243
+ * │ 1 │
244
+ * │ 2 │
245
+ * └─────┘
246
+ * ```
247
+ */
248
+ function argSortBy(exprs, descending = false) {
249
+ if (!Array.isArray(descending)) {
250
+ descending = Array.from({ length: exprs.length }, () => descending);
251
+ }
252
+ const by = (0, utils_1.selectionToExprList)(exprs);
253
+ return (0, expr_1._Expr)(polars_internal_1.default.argSortBy(by, descending));
254
+ }
255
+ function avg(column) {
256
+ return mean(column);
257
+ }
258
+ function concatList(...exprs) {
259
+ const items = (0, utils_1.selectionToExprList)(exprs, false);
260
+ return expr_1.Expr(polars_internal_1.default.concatLst(items));
261
+ }
262
+ function concatString(opts, sep = ",", ignoreNulls = true) {
263
+ if (opts?.exprs) {
264
+ return concatString(opts.exprs, opts.sep, opts.ignoreNulls);
265
+ }
266
+ const items = (0, utils_1.selectionToExprList)(opts, false);
267
+ return expr_1.Expr(polars_internal_1.default.concatStr(items, sep, ignoreNulls));
268
+ }
269
+ function count(column) {
270
+ if (series_1.Series.isSeries(column)) {
271
+ return column.len();
272
+ }
273
+ return col(column).count();
274
+ }
275
+ /** Compute the covariance between two columns/ expressions. */
276
+ function cov(a, b, ddof = 1) {
277
+ a = (0, expr_1.exprToLitOrExpr)(a, false);
278
+ b = (0, expr_1.exprToLitOrExpr)(b, false);
279
+ return (0, expr_1._Expr)(polars_internal_1.default.cov(a, b, ddof));
280
+ }
281
+ function exclude(...columns) {
282
+ return col("*").exclude(columns);
283
+ }
284
+ function first(column) {
285
+ if (!column) {
286
+ return (0, expr_1._Expr)(polars_internal_1.default.first());
287
+ }
288
+ if (series_1.Series.isSeries(column)) {
289
+ if (column.length) {
290
+ return column.get(0);
291
+ }
292
+ throw new RangeError("The series is empty, so no first value can be returned.");
293
+ }
294
+ return col(column).first();
295
+ }
296
+ /**
297
+ * String format utility for expressions
298
+ * Note: strings will be interpolated as `col(<value>)`. if you want a literal string, use `lit(<value>)`
299
+ * @example
300
+ * ```
301
+ * > df = pl.DataFrame({
302
+ * ... "a": ["a", "b", "c"],
303
+ * ... "b": [1, 2, 3],
304
+ * ... })
305
+ * > df.select(
306
+ * ... pl.format("foo_{}_bar_{}", pl.col("a"), "b").alias("fmt"),
307
+ * ... )
308
+ * shape: (3, 1)
309
+ * ┌─────────────┐
310
+ * │ fmt │
311
+ * │ --- │
312
+ * │ str │
313
+ * ╞═════════════╡
314
+ * │ foo_a_bar_1 │
315
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
316
+ * │ foo_b_bar_2 │
317
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
318
+ * │ foo_c_bar_3 │
319
+ * └─────────────┘
320
+ *
321
+ * // You can use format as tag function as well
322
+ * > pl.format("foo_{}_bar_{}", pl.col("a"), "b") // is the same as
323
+ * > pl.format`foo_${pl.col("a")}_bar_${"b"}`
324
+ * ```
325
+ */
326
+ function format(strings, ...expr) {
327
+ if (typeof strings === "string") {
328
+ const s = strings.split("{}");
329
+ if (s.length - 1 !== expr.length) {
330
+ throw new RangeError("number of placeholders should equal the number of arguments");
331
+ }
332
+ return format(s, ...expr);
333
+ }
334
+ const d = (0, utils_1.range)(0, Math.max(strings.length, expr.length))
335
+ .flatMap((i) => {
336
+ const sVal = strings[i] ? lit(strings[i]) : [];
337
+ const exprVal = expr[i] ? (0, expr_1.exprToLitOrExpr)(expr[i], false) : [];
338
+ return [sVal, exprVal];
339
+ })
340
+ .flat();
341
+ return concatString(d, "");
342
+ }
343
+ /** Syntactic sugar for `pl.col(column).aggGroups()` */
344
+ function groups(column) {
345
+ return col(column).aggGroups();
346
+ }
347
+ function head(column, n) {
348
+ if (series_1.Series.isSeries(column)) {
349
+ return column.head(n);
350
+ }
351
+ return (0, expr_1.exprToLitOrExpr)(column, false).head(n);
352
+ }
353
+ /** Return the number of elements in the column.
354
+ This is similar to `COUNT(*)` in SQL.
355
+
356
+ @return Expr - Expression of data type :class:`UInt32`.
357
+ @example
358
+ ```
359
+ >>> const df = pl.DataFrame(
360
+ ... {
361
+ ... "a": [1, 2, None],
362
+ ... "b": [3, None, None],
363
+ ... "c": ["foo", "bar", "foo"],
364
+ ... }
365
+ ... )
366
+ >>> df.select(pl.len())
367
+ shape: (1, 1)
368
+ ┌─────┐
369
+ │ len │
370
+ │ --- │
371
+ │ u32 │
372
+ ╞═════╡
373
+ │ 3 │
374
+ └─────┘
375
+ ```
376
+ Generate an index column by using `len` in conjunction with :func:`intRange`.
377
+
378
+ ```
379
+ >>> df.select(
380
+ ... pl.intRange(pl.len(), dtype=pl.UInt32).alias("index"),
381
+ ... pl.all(),
382
+ ... )
383
+ shape: (3, 4)
384
+ ┌───────┬──────┬──────┬─────┐
385
+ │ index ┆ a ┆ b ┆ c │
386
+ │ --- ┆ --- ┆ --- ┆ --- │
387
+ │ u32 ┆ i64 ┆ i64 ┆ str │
388
+ ╞═══════╪══════╪══════╪═════╡
389
+ │ 0 ┆ 1 ┆ 3 ┆ foo │
390
+ │ 1 ┆ 2 ┆ null ┆ bar │
391
+ │ 2 ┆ null ┆ null ┆ foo │
392
+ └───────┴──────┴──────┴─────┘
393
+ ```
394
+ */
395
+ function len() {
396
+ return (0, expr_1._Expr)(polars_internal_1.default.len());
397
+ }
398
+ /** Get the last value. */
399
+ function last(column) {
400
+ if (series_1.Series.isSeries(column)) {
401
+ if (column.length) {
402
+ return column.get(-1);
403
+ }
404
+ throw new RangeError("The series is empty, so no last value can be returned.");
405
+ }
406
+ return (0, expr_1.exprToLitOrExpr)(column, false).last();
407
+ }
408
+ function mean(column) {
409
+ if (series_1.Series.isSeries(column)) {
410
+ return column.mean();
411
+ }
412
+ return (0, expr_1.exprToLitOrExpr)(column, false).mean();
413
+ }
414
+ function median(column) {
415
+ if (series_1.Series.isSeries(column)) {
416
+ return column.median();
417
+ }
418
+ return (0, expr_1.exprToLitOrExpr)(column, false).median();
419
+ }
420
+ function nUnique(column) {
421
+ if (series_1.Series.isSeries(column)) {
422
+ return column.nUnique();
423
+ }
424
+ return (0, expr_1.exprToLitOrExpr)(column, false).nUnique();
425
+ }
426
+ /** Compute the pearson's correlation between two columns. */
427
+ function pearsonCorr(a, b) {
428
+ a = (0, expr_1.exprToLitOrExpr)(a, false);
429
+ b = (0, expr_1.exprToLitOrExpr)(b, false);
430
+ return (0, expr_1._Expr)(polars_internal_1.default.pearsonCorr(a, b));
431
+ }
432
+ function quantile(column, q) {
433
+ if (series_1.Series.isSeries(column)) {
434
+ return column.quantile(q);
435
+ }
436
+ return (0, expr_1.exprToLitOrExpr)(column, false).quantile(q);
437
+ }
438
+ /**
439
+ * __Run polars expressions without a context.__
440
+ *
441
+ * This is syntactic sugar for running `df.select` on an empty DataFrame.
442
+ */
443
+ function select(expr, ...exprs) {
444
+ return (0, dataframe_1.DataFrame)({}).select(expr, ...exprs);
445
+ }
446
+ /** Compute the spearman rank correlation between two columns. */
447
+ function spearmanRankCorr(a, b) {
448
+ a = (0, expr_1.exprToLitOrExpr)(a, false);
449
+ b = (0, expr_1.exprToLitOrExpr)(b, false);
450
+ return (0, expr_1._Expr)(polars_internal_1.default.spearmanRankCorr(a, b, false));
451
+ }
452
+ function tail(column, n) {
453
+ if (series_1.Series.isSeries(column)) {
454
+ return column.tail(n);
455
+ }
456
+ return (0, expr_1.exprToLitOrExpr)(column, false).tail(n);
457
+ }
458
+ /** Syntactic sugar for `pl.col(column).list()` */
459
+ function list(column) {
460
+ return (0, expr_1.exprToLitOrExpr)(column, false).list();
461
+ }
462
+ function struct(exprs) {
463
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
464
+ if (series_1.Series.isSeries(exprs[0])) {
465
+ return select((0, expr_1._Expr)(polars_internal_1.default.asStruct(exprs.map((e) => polars_internal_1.default.lit(e._s).alias(e.name))))).toSeries();
466
+ }
467
+ exprs = (0, utils_1.selectionToExprList)(exprs);
468
+ return (0, expr_1._Expr)(polars_internal_1.default.asStruct(exprs));
469
+ }
470
+ /**
471
+ * Alias for an element in evaluated in an `eval` expression.
472
+
473
+ * @example
474
+ *
475
+ * A horizontal rank computation by taking the elements of a list
476
+ *
477
+ * >df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2]})
478
+ * >df.withColumn(
479
+ * ... pl.concatList(["a", "b"]).arr.eval(pl.element().rank()).alias("rank")
480
+ * ... )
481
+ * shape: (3, 3)
482
+ * ┌─────┬─────┬────────────┐
483
+ * │ a ┆ b ┆ rank │
484
+ * │ --- ┆ --- ┆ --- │
485
+ * │ i64 ┆ i64 ┆ list[f32] │
486
+ * ╞═════╪═════╪════════════╡
487
+ * │ 1 ┆ 4 ┆ [1.0, 2.0] │
488
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
489
+ * │ 8 ┆ 5 ┆ [2.0, 1.0] │
490
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
491
+ * │ 3 ┆ 2 ┆ [2.0, 1.0] │
492
+ * └─────┴─────┴────────────┘
493
+ *
494
+ * A mathematical operation on array elements
495
+ *
496
+ * >df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2]})
497
+ * >df.withColumn(
498
+ * ... pl.concatList(["a", "b"]).arr.eval(pl.element().multiplyBy(2)).alias("a_b_doubled")
499
+ * ... )
500
+ * shape: (3, 3)
501
+ * ┌─────┬─────┬─────────────┐
502
+ * │ a ┆ b ┆ a_b_doubled │
503
+ * │ --- ┆ --- ┆ --- │
504
+ * │ i64 ┆ i64 ┆ list[i64] │
505
+ * ╞═════╪═════╪═════════════╡
506
+ * │ 1 ┆ 4 ┆ [2, 8] │
507
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
508
+ * │ 8 ┆ 5 ┆ [16, 10] │
509
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
510
+ * │ 3 ┆ 2 ┆ [6, 4] │
511
+ * └─────┴─────┴─────────────┘
512
+ */
513
+ function element() {
514
+ return col("");
515
+ }
516
+ /**
517
+ * Compute the bitwise AND horizontally across columns.
518
+ * @param exprs
519
+ * Column(s) to use in the aggregation. Accepts expression input. Strings are
520
+ * parsed as column names, other non-expression inputs are parsed as literals.
521
+ *
522
+ * @example
523
+ * ```
524
+ * >>> const df = pl.DataFrame(
525
+ * {
526
+ * "a": [false, false, true, true],
527
+ * "b": [false, true, null, true],
528
+ * "c": ["w", "x", "y", "z"],
529
+ * }
530
+ * )
531
+ * >>> df.withColumns(pl.allHorizontal([pl.col("a"), pl.col("b")]))
532
+ * shape: (4, 4)
533
+ * ┌───────┬───────┬─────┬───────┐
534
+ * │ a ┆ b ┆ c ┆ all │
535
+ * │ --- ┆ --- ┆ --- ┆ --- │
536
+ * │ bool ┆ bool ┆ str ┆ bool │
537
+ * ╞═══════╪═══════╪═════╪═══════╡
538
+ * │ false ┆ false ┆ w ┆ false │
539
+ * │ false ┆ true ┆ x ┆ false │
540
+ * │ true ┆ null ┆ y ┆ null │
541
+ * │ true ┆ true ┆ z ┆ true │
542
+ * └───────┴───────┴─────┴───────┘
543
+ * ```
544
+ */
545
+ function allHorizontal(exprs) {
546
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
547
+ exprs = (0, utils_1.selectionToExprList)(exprs);
548
+ return (0, expr_1._Expr)(polars_internal_1.default.allHorizontal(exprs));
549
+ }
550
+ /**
551
+ * Compute the bitwise OR horizontally across columns.
552
+ * @param exprs
553
+ * Column(s) to use in the aggregation. Accepts expression input. Strings are
554
+ * parsed as column names, other non-expression inputs are parsed as literals.
555
+ * @example
556
+ * ```
557
+ * >>> const df = pl.DataFrame(
558
+ * ... {
559
+ * ... "a": [false, false, true, null],
560
+ * ... "b": [false, true, null, null],
561
+ * ... "c": ["w", "x", "y", "z"],
562
+ * ... }
563
+ * ... )
564
+ * >>> df.withColumns(pl.anyHorizontal([pl.col("a"), pl.col("b")]))
565
+ * shape: (4, 4)
566
+ * ┌───────┬───────┬─────┬───────┐
567
+ * │ a ┆ b ┆ c ┆ any │
568
+ * │ --- ┆ --- ┆ --- ┆ --- │
569
+ * │ bool ┆ bool ┆ str ┆ bool │
570
+ * ╞═══════╪═══════╪═════╪═══════╡
571
+ * │ false ┆ false ┆ w ┆ false │
572
+ * │ false ┆ true ┆ x ┆ true │
573
+ * │ true ┆ null ┆ y ┆ true │
574
+ * │ null ┆ null ┆ z ┆ null │
575
+ * └───────┴───────┴─────┴───────┘
576
+ * ```
577
+ */
578
+ function anyHorizontal(exprs) {
579
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
580
+ exprs = (0, utils_1.selectionToExprList)(exprs);
581
+ return (0, expr_1._Expr)(polars_internal_1.default.anyHorizontal(exprs));
582
+ }
583
+ /**
584
+ * Get the maximum value horizontally across columns.
585
+ * @param exprs
586
+ * Column(s) to use in the aggregation. Accepts expression input. Strings are
587
+ * parsed as column names, other non-expression inputs are parsed as literals.
588
+ * @example
589
+ * ```
590
+ * >>> const df = pl.DataFrame(
591
+ * ... {
592
+ * ... "a": [1, 8, 3],
593
+ * ... "b": [4, 5, null],
594
+ * ... "c": ["x", "y", "z"],
595
+ * ... }
596
+ * ... )
597
+ * >>> df.withColumns(pl.maxHorizontal(pl.col("a"), pl.col("b")))
598
+ * shape: (3, 4)
599
+ * ┌─────┬──────┬─────┬─────┐
600
+ * │ a ┆ b ┆ c ┆ max │
601
+ * │ --- ┆ --- ┆ --- ┆ --- │
602
+ * │ i64 ┆ i64 ┆ str ┆ i64 │
603
+ * ╞═════╪══════╪═════╪═════╡
604
+ * │ 1 ┆ 4 ┆ x ┆ 4 │
605
+ * │ 8 ┆ 5 ┆ y ┆ 8 │
606
+ * │ 3 ┆ null ┆ z ┆ 3 │
607
+ * └─────┴──────┴─────┴─────┘
608
+ * ```
609
+ */
610
+ function maxHorizontal(exprs) {
611
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
612
+ exprs = (0, utils_1.selectionToExprList)(exprs);
613
+ return (0, expr_1._Expr)(polars_internal_1.default.maxHorizontal(exprs));
614
+ }
615
+ /**
616
+ * Get the minimum value horizontally across columns.
617
+ * @param exprs Column(s) to use in the aggregation. Accepts expression input. Strings are
618
+ * parsed as column names, other non-expression inputs are parsed as literals.
619
+ * @example
620
+ * ```
621
+ * >>> const df = pl.DataFrame(
622
+ * ... {
623
+ * ... "a": [1, 8, 3],
624
+ * ... "b": [4, 5, null],
625
+ * ... "c": ["x", "y", "z"],
626
+ * ... }
627
+ * ... )
628
+ * >>> df.withColumns(pl.minHorizontal(pl.col("a"), pl.col("b")))
629
+ * shape: (3, 4)
630
+ * ┌─────┬──────┬─────┬─────┐
631
+ * │ a ┆ b ┆ c ┆ min │
632
+ * │ --- ┆ --- ┆ --- ┆ --- │
633
+ * │ i64 ┆ i64 ┆ str ┆ i64 │
634
+ * ╞═════╪══════╪═════╪═════╡
635
+ * │ 1 ┆ 4 ┆ x ┆ 1 │
636
+ * │ 8 ┆ 5 ┆ y ┆ 5 │
637
+ * │ 3 ┆ null ┆ z ┆ 3 │
638
+ * └─────┴──────┴─────┴─────┘
639
+ * ```
640
+ */
641
+ function minHorizontal(exprs) {
642
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
643
+ exprs = (0, utils_1.selectionToExprList)(exprs);
644
+ return (0, expr_1._Expr)(polars_internal_1.default.minHorizontal(exprs));
645
+ }
646
+ /**
647
+ * Sum all values horizontally across columns.
648
+ * @param exprs
649
+ * Column(s) to use in the aggregation. Accepts expression input. Strings are
650
+ * parsed as column names, other non-expression inputs are parsed as literals.
651
+ * @example
652
+ * ```
653
+ * >>> const df = pl.DataFrame(
654
+ * ... {
655
+ * ... "a": [1, 8, 3],
656
+ * ... "b": [4, 5, null],
657
+ * ... "c": ["x", "y", "z"],
658
+ * ... }
659
+ * ... )
660
+ * >>> df.withColumns(pl.sumHorizontal(pl.col("a"), ol.col("b")))
661
+ * shape: (3, 4)
662
+ * ┌─────┬──────┬─────┬──────┐
663
+ * │ a ┆ b ┆ c ┆ sum │
664
+ * │ --- ┆ --- ┆ --- ┆ --- │
665
+ * │ i64 ┆ i64 ┆ str ┆ i64 │
666
+ * ╞═════╪══════╪═════╪══════╡
667
+ * │ 1 ┆ 4 ┆ x ┆ 5 │
668
+ * │ 8 ┆ 5 ┆ y ┆ 13 │
669
+ * │ 3 ┆ null ┆ z ┆ null │
670
+ * └─────┴──────┴─────┴──────┘
671
+ * ```
672
+ */
673
+ function sumHorizontal(exprs) {
674
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
675
+ exprs = (0, utils_1.selectionToExprList)(exprs);
676
+ return (0, expr_1._Expr)(polars_internal_1.default.sumHorizontal(exprs, true));
677
+ }
678
+ // // export function collect_all() {}
679
+ // // export function all() {} // fold
680
+ // // export function any() {} // fold
681
+ // // export function apply() {} // lambda
682
+ // // export function fold() {}
683
+ // // export function map_binary() {} //lambda
684
+ // // export function map() {} //lambda
685
+ // // export function max() {} // fold
686
+ // // export function min() {} // fold
687
+ // // export function sum() {} // fold