@ohos-ports/nodejs-polars 0.22.2-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 +2008 -0
  6. package/bin/dataframe.js +771 -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 +252 -0
  10. package/bin/datatypes/datatype.js +386 -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 +42 -0
  14. package/bin/datatypes/index.js +119 -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 +173 -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 +252 -0
  24. package/bin/index.js +265 -0
  25. package/bin/internals/construction.d.ts +7 -0
  26. package/bin/internals/construction.js +237 -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 +421 -0
  30. package/bin/io.js +332 -0
  31. package/bin/lazy/dataframe.d.ts +693 -0
  32. package/bin/lazy/dataframe.js +421 -0
  33. package/bin/lazy/expr/datetime.d.ts +8 -0
  34. package/bin/lazy/expr/datetime.js +25 -0
  35. package/bin/lazy/expr/index.d.ts +1155 -0
  36. package/bin/lazy/expr/index.js +629 -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 +620 -0
  44. package/bin/lazy/functions.js +691 -0
  45. package/bin/lazy/groupby.d.ts +24 -0
  46. package/bin/lazy/groupby.js +22 -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 +25 -0
  55. package/bin/series/index.d.ts +1116 -0
  56. package/bin/series/index.js +689 -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 +1325 -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 +284 -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 +51 -0
@@ -0,0 +1,691 @@
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
+ // @deprecated since 0.15.0
194
+ if (typeof opts?.low === "number") {
195
+ return intRange(opts.low, opts.high, opts.step, opts.dtype, opts.eager);
196
+ }
197
+ if (typeof opts?.start === "number") {
198
+ return intRange(opts.start, opts.end, opts.step, opts.dtype, opts.eager);
199
+ }
200
+ // if expression like pl.len() passed
201
+ if (end === undefined || end === null) {
202
+ end = opts;
203
+ opts = 0;
204
+ }
205
+ const start = (0, expr_1.exprToLitOrExpr)(opts, false);
206
+ end = (0, expr_1.exprToLitOrExpr)(end, false);
207
+ if (eager) {
208
+ const df = (0, dataframe_1.DataFrame)({ a: [1] });
209
+ return df
210
+ .select(intRange(start, end, step).alias("intRange"))
211
+ .getColumn("intRange");
212
+ }
213
+ return (0, expr_1._Expr)(polars_internal_1.default.intRange(start, end, step, dtype || datatypes_1.DataType.Int64));
214
+ }
215
+ function intRanges(start, end, step = 1, dtype = datatypes_1.DataType.Int64, eager) {
216
+ start = (0, expr_1.exprToLitOrExpr)(start, false);
217
+ end = (0, expr_1.exprToLitOrExpr)(end, false);
218
+ step = (0, expr_1.exprToLitOrExpr)(step, false);
219
+ if (eager) {
220
+ const df = (0, dataframe_1.DataFrame)({ a: [1] });
221
+ return df
222
+ .select(intRanges(start, end, step, dtype).alias("intRanges"))
223
+ .getColumn("intRanges");
224
+ }
225
+ return (0, expr_1._Expr)(polars_internal_1.default.intRanges(start, end, step, dtype));
226
+ }
227
+ /** Alias for `pl.col("*")` */
228
+ function all() {
229
+ return col("*");
230
+ }
231
+ /**
232
+ * Return the row indices that would sort the columns.
233
+ * @param exprs Column(s) to arg sort by. Accepts expression input.
234
+ * @param descending Sort in descending order. When sorting by multiple columns, can be specified per column by passing a sequence of booleans.
235
+ * @example
236
+ * ```
237
+ * const df = pl.DataFrame({"a": [0, 1, 1, 0], "b": [3, 2, 3, 2],});
238
+ * df.select(pl.argSortBy(pl.col("a")));
239
+ * shape: (4, 1)
240
+ * ┌─────┐
241
+ * │ a │
242
+ * │ --- │
243
+ * │ u32 │
244
+ * ╞═════╡
245
+ * │ 0 │
246
+ * │ 3 │
247
+ * │ 1 │
248
+ * │ 2 │
249
+ * └─────┘
250
+ * ```
251
+ */
252
+ function argSortBy(exprs, descending = false) {
253
+ if (!Array.isArray(descending)) {
254
+ descending = Array.from({ length: exprs.length }, () => descending);
255
+ }
256
+ const by = (0, utils_1.selectionToExprList)(exprs);
257
+ return (0, expr_1._Expr)(polars_internal_1.default.argSortBy(by, descending));
258
+ }
259
+ function avg(column) {
260
+ return mean(column);
261
+ }
262
+ function concatList(...exprs) {
263
+ const items = (0, utils_1.selectionToExprList)(exprs, false);
264
+ return expr_1.Expr(polars_internal_1.default.concatLst(items));
265
+ }
266
+ function concatString(opts, sep = ",", ignoreNulls = true) {
267
+ if (opts?.exprs) {
268
+ return concatString(opts.exprs, opts.sep, opts.ignoreNulls);
269
+ }
270
+ const items = (0, utils_1.selectionToExprList)(opts, false);
271
+ return expr_1.Expr(polars_internal_1.default.concatStr(items, sep, ignoreNulls));
272
+ }
273
+ function count(column) {
274
+ if (series_1.Series.isSeries(column)) {
275
+ return column.len();
276
+ }
277
+ return col(column).count();
278
+ }
279
+ /** Compute the covariance between two columns/ expressions. */
280
+ function cov(a, b, ddof = 1) {
281
+ a = (0, expr_1.exprToLitOrExpr)(a, false);
282
+ b = (0, expr_1.exprToLitOrExpr)(b, false);
283
+ return (0, expr_1._Expr)(polars_internal_1.default.cov(a, b, ddof));
284
+ }
285
+ function exclude(...columns) {
286
+ return col("*").exclude(columns);
287
+ }
288
+ function first(column) {
289
+ if (!column) {
290
+ return (0, expr_1._Expr)(polars_internal_1.default.first());
291
+ }
292
+ if (series_1.Series.isSeries(column)) {
293
+ if (column.length) {
294
+ return column.get(0);
295
+ }
296
+ throw new RangeError("The series is empty, so no first value can be returned.");
297
+ }
298
+ return col(column).first();
299
+ }
300
+ /**
301
+ * String format utility for expressions
302
+ * Note: strings will be interpolated as `col(<value>)`. if you want a literal string, use `lit(<value>)`
303
+ * @example
304
+ * ```
305
+ * > df = pl.DataFrame({
306
+ * ... "a": ["a", "b", "c"],
307
+ * ... "b": [1, 2, 3],
308
+ * ... })
309
+ * > df.select(
310
+ * ... pl.format("foo_{}_bar_{}", pl.col("a"), "b").alias("fmt"),
311
+ * ... )
312
+ * shape: (3, 1)
313
+ * ┌─────────────┐
314
+ * │ fmt │
315
+ * │ --- │
316
+ * │ str │
317
+ * ╞═════════════╡
318
+ * │ foo_a_bar_1 │
319
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
320
+ * │ foo_b_bar_2 │
321
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
322
+ * │ foo_c_bar_3 │
323
+ * └─────────────┘
324
+ *
325
+ * // You can use format as tag function as well
326
+ * > pl.format("foo_{}_bar_{}", pl.col("a"), "b") // is the same as
327
+ * > pl.format`foo_${pl.col("a")}_bar_${"b"}`
328
+ * ```
329
+ */
330
+ function format(strings, ...expr) {
331
+ if (typeof strings === "string") {
332
+ const s = strings.split("{}");
333
+ if (s.length - 1 !== expr.length) {
334
+ throw new RangeError("number of placeholders should equal the number of arguments");
335
+ }
336
+ return format(s, ...expr);
337
+ }
338
+ const d = (0, utils_1.range)(0, Math.max(strings.length, expr.length))
339
+ .flatMap((i) => {
340
+ const sVal = strings[i] ? lit(strings[i]) : [];
341
+ const exprVal = expr[i] ? (0, expr_1.exprToLitOrExpr)(expr[i], false) : [];
342
+ return [sVal, exprVal];
343
+ })
344
+ .flat();
345
+ return concatString(d, "");
346
+ }
347
+ /** Syntactic sugar for `pl.col(column).aggGroups()` */
348
+ function groups(column) {
349
+ return col(column).aggGroups();
350
+ }
351
+ function head(column, n) {
352
+ if (series_1.Series.isSeries(column)) {
353
+ return column.head(n);
354
+ }
355
+ return (0, expr_1.exprToLitOrExpr)(column, false).head(n);
356
+ }
357
+ /** Return the number of elements in the column.
358
+ This is similar to `COUNT(*)` in SQL.
359
+
360
+ @return Expr - Expression of data type :class:`UInt32`.
361
+ @example
362
+ ```
363
+ >>> const df = pl.DataFrame(
364
+ ... {
365
+ ... "a": [1, 2, None],
366
+ ... "b": [3, None, None],
367
+ ... "c": ["foo", "bar", "foo"],
368
+ ... }
369
+ ... )
370
+ >>> df.select(pl.len())
371
+ shape: (1, 1)
372
+ ┌─────┐
373
+ │ len │
374
+ │ --- │
375
+ │ u32 │
376
+ ╞═════╡
377
+ │ 3 │
378
+ └─────┘
379
+ ```
380
+ Generate an index column by using `len` in conjunction with :func:`intRange`.
381
+
382
+ ```
383
+ >>> df.select(
384
+ ... pl.intRange(pl.len(), dtype=pl.UInt32).alias("index"),
385
+ ... pl.all(),
386
+ ... )
387
+ shape: (3, 4)
388
+ ┌───────┬──────┬──────┬─────┐
389
+ │ index ┆ a ┆ b ┆ c │
390
+ │ --- ┆ --- ┆ --- ┆ --- │
391
+ │ u32 ┆ i64 ┆ i64 ┆ str │
392
+ ╞═══════╪══════╪══════╪═════╡
393
+ │ 0 ┆ 1 ┆ 3 ┆ foo │
394
+ │ 1 ┆ 2 ┆ null ┆ bar │
395
+ │ 2 ┆ null ┆ null ┆ foo │
396
+ └───────┴──────┴──────┴─────┘
397
+ ```
398
+ */
399
+ function len() {
400
+ return (0, expr_1._Expr)(polars_internal_1.default.len());
401
+ }
402
+ /** Get the last value. */
403
+ function last(column) {
404
+ if (series_1.Series.isSeries(column)) {
405
+ if (column.length) {
406
+ return column.get(-1);
407
+ }
408
+ throw new RangeError("The series is empty, so no last value can be returned.");
409
+ }
410
+ return (0, expr_1.exprToLitOrExpr)(column, false).last();
411
+ }
412
+ function mean(column) {
413
+ if (series_1.Series.isSeries(column)) {
414
+ return column.mean();
415
+ }
416
+ return (0, expr_1.exprToLitOrExpr)(column, false).mean();
417
+ }
418
+ function median(column) {
419
+ if (series_1.Series.isSeries(column)) {
420
+ return column.median();
421
+ }
422
+ return (0, expr_1.exprToLitOrExpr)(column, false).median();
423
+ }
424
+ function nUnique(column) {
425
+ if (series_1.Series.isSeries(column)) {
426
+ return column.nUnique();
427
+ }
428
+ return (0, expr_1.exprToLitOrExpr)(column, false).nUnique();
429
+ }
430
+ /** Compute the pearson's correlation between two columns. */
431
+ function pearsonCorr(a, b) {
432
+ a = (0, expr_1.exprToLitOrExpr)(a, false);
433
+ b = (0, expr_1.exprToLitOrExpr)(b, false);
434
+ return (0, expr_1._Expr)(polars_internal_1.default.pearsonCorr(a, b));
435
+ }
436
+ function quantile(column, q) {
437
+ if (series_1.Series.isSeries(column)) {
438
+ return column.quantile(q);
439
+ }
440
+ return (0, expr_1.exprToLitOrExpr)(column, false).quantile(q);
441
+ }
442
+ /**
443
+ * __Run polars expressions without a context.__
444
+ *
445
+ * This is syntactic sugar for running `df.select` on an empty DataFrame.
446
+ */
447
+ function select(expr, ...exprs) {
448
+ return (0, dataframe_1.DataFrame)({}).select(expr, ...exprs);
449
+ }
450
+ /** Compute the spearman rank correlation between two columns. */
451
+ function spearmanRankCorr(a, b) {
452
+ a = (0, expr_1.exprToLitOrExpr)(a, false);
453
+ b = (0, expr_1.exprToLitOrExpr)(b, false);
454
+ return (0, expr_1._Expr)(polars_internal_1.default.spearmanRankCorr(a, b, false));
455
+ }
456
+ function tail(column, n) {
457
+ if (series_1.Series.isSeries(column)) {
458
+ return column.tail(n);
459
+ }
460
+ return (0, expr_1.exprToLitOrExpr)(column, false).tail(n);
461
+ }
462
+ /** Syntactic sugar for `pl.col(column).list()` */
463
+ function list(column) {
464
+ return (0, expr_1.exprToLitOrExpr)(column, false).list();
465
+ }
466
+ function struct(exprs) {
467
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
468
+ if (series_1.Series.isSeries(exprs[0])) {
469
+ 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();
470
+ }
471
+ exprs = (0, utils_1.selectionToExprList)(exprs);
472
+ return (0, expr_1._Expr)(polars_internal_1.default.asStruct(exprs));
473
+ }
474
+ /**
475
+ * Alias for an element in evaluated in an `eval` expression.
476
+
477
+ * @example
478
+ *
479
+ * A horizontal rank computation by taking the elements of a list
480
+ *
481
+ * >df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2]})
482
+ * >df.withColumn(
483
+ * ... pl.concatList(["a", "b"]).arr.eval(pl.element().rank()).alias("rank")
484
+ * ... )
485
+ * shape: (3, 3)
486
+ * ┌─────┬─────┬────────────┐
487
+ * │ a ┆ b ┆ rank │
488
+ * │ --- ┆ --- ┆ --- │
489
+ * │ i64 ┆ i64 ┆ list[f32] │
490
+ * ╞═════╪═════╪════════════╡
491
+ * │ 1 ┆ 4 ┆ [1.0, 2.0] │
492
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
493
+ * │ 8 ┆ 5 ┆ [2.0, 1.0] │
494
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
495
+ * │ 3 ┆ 2 ┆ [2.0, 1.0] │
496
+ * └─────┴─────┴────────────┘
497
+ *
498
+ * A mathematical operation on array elements
499
+ *
500
+ * >df = pl.DataFrame({"a": [1, 8, 3], "b": [4, 5, 2]})
501
+ * >df.withColumn(
502
+ * ... pl.concatList(["a", "b"]).arr.eval(pl.element().multiplyBy(2)).alias("a_b_doubled")
503
+ * ... )
504
+ * shape: (3, 3)
505
+ * ┌─────┬─────┬─────────────┐
506
+ * │ a ┆ b ┆ a_b_doubled │
507
+ * │ --- ┆ --- ┆ --- │
508
+ * │ i64 ┆ i64 ┆ list[i64] │
509
+ * ╞═════╪═════╪═════════════╡
510
+ * │ 1 ┆ 4 ┆ [2, 8] │
511
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
512
+ * │ 8 ┆ 5 ┆ [16, 10] │
513
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌┤
514
+ * │ 3 ┆ 2 ┆ [6, 4] │
515
+ * └─────┴─────┴─────────────┘
516
+ */
517
+ function element() {
518
+ return col("");
519
+ }
520
+ /**
521
+ * Compute the bitwise AND horizontally across columns.
522
+ * @param exprs
523
+ * Column(s) to use in the aggregation. Accepts expression input. Strings are
524
+ * parsed as column names, other non-expression inputs are parsed as literals.
525
+ *
526
+ * @example
527
+ * ```
528
+ * >>> const df = pl.DataFrame(
529
+ * {
530
+ * "a": [false, false, true, true],
531
+ * "b": [false, true, null, true],
532
+ * "c": ["w", "x", "y", "z"],
533
+ * }
534
+ * )
535
+ * >>> df.withColumns(pl.allHorizontal([pl.col("a"), pl.col("b")]))
536
+ * shape: (4, 4)
537
+ * ┌───────┬───────┬─────┬───────┐
538
+ * │ a ┆ b ┆ c ┆ all │
539
+ * │ --- ┆ --- ┆ --- ┆ --- │
540
+ * │ bool ┆ bool ┆ str ┆ bool │
541
+ * ╞═══════╪═══════╪═════╪═══════╡
542
+ * │ false ┆ false ┆ w ┆ false │
543
+ * │ false ┆ true ┆ x ┆ false │
544
+ * │ true ┆ null ┆ y ┆ null │
545
+ * │ true ┆ true ┆ z ┆ true │
546
+ * └───────┴───────┴─────┴───────┘
547
+ * ```
548
+ */
549
+ function allHorizontal(exprs) {
550
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
551
+ exprs = (0, utils_1.selectionToExprList)(exprs);
552
+ return (0, expr_1._Expr)(polars_internal_1.default.allHorizontal(exprs));
553
+ }
554
+ /**
555
+ * Compute the bitwise OR horizontally across columns.
556
+ * @param exprs
557
+ * Column(s) to use in the aggregation. Accepts expression input. Strings are
558
+ * parsed as column names, other non-expression inputs are parsed as literals.
559
+ * @example
560
+ * ```
561
+ * >>> const df = pl.DataFrame(
562
+ * ... {
563
+ * ... "a": [false, false, true, null],
564
+ * ... "b": [false, true, null, null],
565
+ * ... "c": ["w", "x", "y", "z"],
566
+ * ... }
567
+ * ... )
568
+ * >>> df.withColumns(pl.anyHorizontal([pl.col("a"), pl.col("b")]))
569
+ * shape: (4, 4)
570
+ * ┌───────┬───────┬─────┬───────┐
571
+ * │ a ┆ b ┆ c ┆ any │
572
+ * │ --- ┆ --- ┆ --- ┆ --- │
573
+ * │ bool ┆ bool ┆ str ┆ bool │
574
+ * ╞═══════╪═══════╪═════╪═══════╡
575
+ * │ false ┆ false ┆ w ┆ false │
576
+ * │ false ┆ true ┆ x ┆ true │
577
+ * │ true ┆ null ┆ y ┆ true │
578
+ * │ null ┆ null ┆ z ┆ null │
579
+ * └───────┴───────┴─────┴───────┘
580
+ * ```
581
+ */
582
+ function anyHorizontal(exprs) {
583
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
584
+ exprs = (0, utils_1.selectionToExprList)(exprs);
585
+ return (0, expr_1._Expr)(polars_internal_1.default.anyHorizontal(exprs));
586
+ }
587
+ /**
588
+ * Get the maximum value horizontally across columns.
589
+ * @param exprs
590
+ * Column(s) to use in the aggregation. Accepts expression input. Strings are
591
+ * parsed as column names, other non-expression inputs are parsed as literals.
592
+ * @example
593
+ * ```
594
+ * >>> const df = pl.DataFrame(
595
+ * ... {
596
+ * ... "a": [1, 8, 3],
597
+ * ... "b": [4, 5, null],
598
+ * ... "c": ["x", "y", "z"],
599
+ * ... }
600
+ * ... )
601
+ * >>> df.withColumns(pl.maxHorizontal(pl.col("a"), pl.col("b")))
602
+ * shape: (3, 4)
603
+ * ┌─────┬──────┬─────┬─────┐
604
+ * │ a ┆ b ┆ c ┆ max │
605
+ * │ --- ┆ --- ┆ --- ┆ --- │
606
+ * │ i64 ┆ i64 ┆ str ┆ i64 │
607
+ * ╞═════╪══════╪═════╪═════╡
608
+ * │ 1 ┆ 4 ┆ x ┆ 4 │
609
+ * │ 8 ┆ 5 ┆ y ┆ 8 │
610
+ * │ 3 ┆ null ┆ z ┆ 3 │
611
+ * └─────┴──────┴─────┴─────┘
612
+ * ```
613
+ */
614
+ function maxHorizontal(exprs) {
615
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
616
+ exprs = (0, utils_1.selectionToExprList)(exprs);
617
+ return (0, expr_1._Expr)(polars_internal_1.default.maxHorizontal(exprs));
618
+ }
619
+ /**
620
+ * Get the minimum value horizontally across columns.
621
+ * @param exprs Column(s) to use in the aggregation. Accepts expression input. Strings are
622
+ * parsed as column names, other non-expression inputs are parsed as literals.
623
+ * @example
624
+ * ```
625
+ * >>> const df = pl.DataFrame(
626
+ * ... {
627
+ * ... "a": [1, 8, 3],
628
+ * ... "b": [4, 5, null],
629
+ * ... "c": ["x", "y", "z"],
630
+ * ... }
631
+ * ... )
632
+ * >>> df.withColumns(pl.minHorizontal(pl.col("a"), pl.col("b")))
633
+ * shape: (3, 4)
634
+ * ┌─────┬──────┬─────┬─────┐
635
+ * │ a ┆ b ┆ c ┆ min │
636
+ * │ --- ┆ --- ┆ --- ┆ --- │
637
+ * │ i64 ┆ i64 ┆ str ┆ i64 │
638
+ * ╞═════╪══════╪═════╪═════╡
639
+ * │ 1 ┆ 4 ┆ x ┆ 1 │
640
+ * │ 8 ┆ 5 ┆ y ┆ 5 │
641
+ * │ 3 ┆ null ┆ z ┆ 3 │
642
+ * └─────┴──────┴─────┴─────┘
643
+ * ```
644
+ */
645
+ function minHorizontal(exprs) {
646
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
647
+ exprs = (0, utils_1.selectionToExprList)(exprs);
648
+ return (0, expr_1._Expr)(polars_internal_1.default.minHorizontal(exprs));
649
+ }
650
+ /**
651
+ * Sum all values horizontally across columns.
652
+ * @param exprs
653
+ * Column(s) to use in the aggregation. Accepts expression input. Strings are
654
+ * parsed as column names, other non-expression inputs are parsed as literals.
655
+ * @example
656
+ * ```
657
+ * >>> const df = pl.DataFrame(
658
+ * ... {
659
+ * ... "a": [1, 8, 3],
660
+ * ... "b": [4, 5, null],
661
+ * ... "c": ["x", "y", "z"],
662
+ * ... }
663
+ * ... )
664
+ * >>> df.withColumns(pl.sumHorizontal(pl.col("a"), ol.col("b")))
665
+ * shape: (3, 4)
666
+ * ┌─────┬──────┬─────┬──────┐
667
+ * │ a ┆ b ┆ c ┆ sum │
668
+ * │ --- ┆ --- ┆ --- ┆ --- │
669
+ * │ i64 ┆ i64 ┆ str ┆ i64 │
670
+ * ╞═════╪══════╪═════╪══════╡
671
+ * │ 1 ┆ 4 ┆ x ┆ 5 │
672
+ * │ 8 ┆ 5 ┆ y ┆ 13 │
673
+ * │ 3 ┆ null ┆ z ┆ null │
674
+ * └─────┴──────┴─────┴──────┘
675
+ * ```
676
+ */
677
+ function sumHorizontal(exprs) {
678
+ exprs = Array.isArray(exprs) ? exprs : [exprs];
679
+ exprs = (0, utils_1.selectionToExprList)(exprs);
680
+ return (0, expr_1._Expr)(polars_internal_1.default.sumHorizontal(exprs, true));
681
+ }
682
+ // // export function collect_all() {}
683
+ // // export function all() {} // fold
684
+ // // export function any() {} // fold
685
+ // // export function apply() {} // lambda
686
+ // // export function fold() {}
687
+ // // export function map_binary() {} //lambda
688
+ // // export function map() {} //lambda
689
+ // // export function max() {} // fold
690
+ // // export function min() {} // fold
691
+ // // export function sum() {} // fold