@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.
- package/LICENSE +19 -0
- package/README.md +217 -0
- package/bin/cfg.d.ts +156 -0
- package/bin/cfg.js +52 -0
- package/bin/dataframe.d.ts +2008 -0
- package/bin/dataframe.js +771 -0
- package/bin/datatypes/conversion.d.ts +2 -0
- package/bin/datatypes/conversion.js +2 -0
- package/bin/datatypes/datatype.d.ts +252 -0
- package/bin/datatypes/datatype.js +386 -0
- package/bin/datatypes/field.d.ts +26 -0
- package/bin/datatypes/field.js +36 -0
- package/bin/datatypes/index.d.ts +42 -0
- package/bin/datatypes/index.js +119 -0
- package/bin/error.d.ts +7 -0
- package/bin/error.js +17 -0
- package/bin/functions.d.ts +26 -0
- package/bin/functions.js +208 -0
- package/bin/groupby.d.ts +173 -0
- package/bin/groupby.js +156 -0
- package/bin/html.d.ts +4 -0
- package/bin/html.js +18 -0
- package/bin/index.d.ts +252 -0
- package/bin/index.js +265 -0
- package/bin/internals/construction.d.ts +7 -0
- package/bin/internals/construction.js +237 -0
- package/bin/internals/polars_internal.d.ts +2 -0
- package/bin/internals/polars_internal.js +7 -0
- package/bin/io.d.ts +421 -0
- package/bin/io.js +332 -0
- package/bin/lazy/dataframe.d.ts +693 -0
- package/bin/lazy/dataframe.js +421 -0
- package/bin/lazy/expr/datetime.d.ts +8 -0
- package/bin/lazy/expr/datetime.js +25 -0
- package/bin/lazy/expr/index.d.ts +1155 -0
- package/bin/lazy/expr/index.js +629 -0
- package/bin/lazy/expr/list.d.ts +8 -0
- package/bin/lazy/expr/list.js +115 -0
- package/bin/lazy/expr/string.d.ts +534 -0
- package/bin/lazy/expr/string.js +131 -0
- package/bin/lazy/expr/struct.d.ts +126 -0
- package/bin/lazy/expr/struct.js +26 -0
- package/bin/lazy/functions.d.ts +620 -0
- package/bin/lazy/functions.js +691 -0
- package/bin/lazy/groupby.d.ts +24 -0
- package/bin/lazy/groupby.js +22 -0
- package/bin/lazy/index.d.ts +4 -0
- package/bin/lazy/index.js +20 -0
- package/bin/lazy/whenthen.d.ts +67 -0
- package/bin/lazy/whenthen.js +81 -0
- package/bin/native-polars.d.ts +2 -0
- package/bin/native-polars.js +267 -0
- package/bin/series/datetime.d.ts +8 -0
- package/bin/series/datetime.js +25 -0
- package/bin/series/index.d.ts +1116 -0
- package/bin/series/index.js +689 -0
- package/bin/series/list.d.ts +8 -0
- package/bin/series/list.js +87 -0
- package/bin/series/string.d.ts +300 -0
- package/bin/series/string.js +125 -0
- package/bin/series/struct.d.ts +36 -0
- package/bin/series/struct.js +35 -0
- package/bin/shared_traits.d.ts +1325 -0
- package/bin/shared_traits.js +2 -0
- package/bin/sql.d.ts +244 -0
- package/bin/sql.js +63 -0
- package/bin/types.d.ts +284 -0
- package/bin/types.js +2 -0
- package/bin/utils.d.ts +38 -0
- package/bin/utils.js +69 -0
- package/package.json +51 -0
|
@@ -0,0 +1,421 @@
|
|
|
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.LazyDataFrame = exports._LazyDataFrame = void 0;
|
|
7
|
+
const dataframe_1 = require("../dataframe");
|
|
8
|
+
const polars_internal_1 = __importDefault(require("../internals/polars_internal"));
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const expr_1 = require("./expr");
|
|
11
|
+
const groupby_1 = require("./groupby");
|
|
12
|
+
const inspect = Symbol.for("nodejs.util.inspect.custom");
|
|
13
|
+
const prepareGroupbyInputs = (by) => {
|
|
14
|
+
if (Array.isArray(by)) {
|
|
15
|
+
const newBy = [];
|
|
16
|
+
for (let e of by) {
|
|
17
|
+
if (typeof e === "string") {
|
|
18
|
+
e = polars_internal_1.default.col(e);
|
|
19
|
+
}
|
|
20
|
+
newBy.push(e);
|
|
21
|
+
}
|
|
22
|
+
return newBy;
|
|
23
|
+
}
|
|
24
|
+
if (typeof by === "string") {
|
|
25
|
+
return [polars_internal_1.default.col(by)];
|
|
26
|
+
}
|
|
27
|
+
if (expr_1.Expr.isExpr(by)) {
|
|
28
|
+
return [by._expr];
|
|
29
|
+
}
|
|
30
|
+
return [];
|
|
31
|
+
};
|
|
32
|
+
/** @ignore */
|
|
33
|
+
const _LazyDataFrame = (_ldf) => {
|
|
34
|
+
const unwrap = (method, ...args) => {
|
|
35
|
+
return _ldf[method](...args);
|
|
36
|
+
};
|
|
37
|
+
const wrap = (method, ...args) => {
|
|
38
|
+
return (0, exports._LazyDataFrame)(unwrap(method, ...args));
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
_ldf,
|
|
42
|
+
[inspect]() {
|
|
43
|
+
return _ldf.describeOptimizedPlan();
|
|
44
|
+
},
|
|
45
|
+
get [Symbol.toStringTag]() {
|
|
46
|
+
return "LazyDataFrame";
|
|
47
|
+
},
|
|
48
|
+
get columns() {
|
|
49
|
+
return _ldf.columns;
|
|
50
|
+
},
|
|
51
|
+
describePlan() {
|
|
52
|
+
return _ldf.describePlan();
|
|
53
|
+
},
|
|
54
|
+
describeOptimizedPlan() {
|
|
55
|
+
return _ldf.describeOptimizedPlan();
|
|
56
|
+
},
|
|
57
|
+
cache() {
|
|
58
|
+
return (0, exports._LazyDataFrame)(_ldf.cache());
|
|
59
|
+
},
|
|
60
|
+
clone() {
|
|
61
|
+
return (0, exports._LazyDataFrame)(_ldf.clone());
|
|
62
|
+
},
|
|
63
|
+
collectSync() {
|
|
64
|
+
return (0, dataframe_1._DataFrame)(_ldf.collectSync());
|
|
65
|
+
},
|
|
66
|
+
collect(opts) {
|
|
67
|
+
if (opts?.noOptimization) {
|
|
68
|
+
opts.predicatePushdown = false;
|
|
69
|
+
opts.projectionPushdown = false;
|
|
70
|
+
opts.slicePushdown = false;
|
|
71
|
+
opts.commSubplanElim = false;
|
|
72
|
+
opts.commSubexprElim = false;
|
|
73
|
+
}
|
|
74
|
+
if (opts?.streaming)
|
|
75
|
+
opts.commSubplanElim = false;
|
|
76
|
+
if (opts) {
|
|
77
|
+
_ldf = _ldf.optimizationToggle(opts.typeCoercion, opts.predicatePushdown, opts.projectionPushdown, opts.simplifyExpression, opts.slicePushdown, opts.commSubplanElim, opts.commSubexprElim, opts.streaming);
|
|
78
|
+
}
|
|
79
|
+
return _ldf.collect().then(dataframe_1._DataFrame);
|
|
80
|
+
},
|
|
81
|
+
drop(...cols) {
|
|
82
|
+
return (0, exports._LazyDataFrame)(_ldf.dropColumns(cols.flat(2)));
|
|
83
|
+
},
|
|
84
|
+
unique(opts = false, subset, keep = "first") {
|
|
85
|
+
const defaultOptions = {
|
|
86
|
+
maintainOrder: false,
|
|
87
|
+
keep: "first",
|
|
88
|
+
};
|
|
89
|
+
if (typeof opts === "boolean") {
|
|
90
|
+
const o = { ...defaultOptions, maintainOrder: opts, subset, keep };
|
|
91
|
+
return (0, exports._LazyDataFrame)(_ldf.unique(o.maintainOrder, o?.subset?.flat(2), o.keep));
|
|
92
|
+
}
|
|
93
|
+
if (opts.subset) {
|
|
94
|
+
opts.subset = [opts.subset].flat(3);
|
|
95
|
+
}
|
|
96
|
+
const o = { ...defaultOptions, ...opts };
|
|
97
|
+
return (0, exports._LazyDataFrame)(_ldf.unique(o.maintainOrder, o.subset, o.keep));
|
|
98
|
+
},
|
|
99
|
+
dropNulls(...subset) {
|
|
100
|
+
if (subset.length) {
|
|
101
|
+
return wrap("dropNulls", subset.flat(2));
|
|
102
|
+
}
|
|
103
|
+
return wrap("dropNulls");
|
|
104
|
+
},
|
|
105
|
+
explode(...columns) {
|
|
106
|
+
if (!columns.length) {
|
|
107
|
+
const cols = (0, utils_1.selectionToExprList)(_ldf.columns, false);
|
|
108
|
+
return wrap("explode", cols);
|
|
109
|
+
}
|
|
110
|
+
const column = (0, utils_1.selectionToExprList)(columns, false);
|
|
111
|
+
return wrap("explode", column);
|
|
112
|
+
},
|
|
113
|
+
fetchSync(numRows, opts) {
|
|
114
|
+
if (opts?.noOptimization) {
|
|
115
|
+
opts.predicatePushdown = false;
|
|
116
|
+
opts.projectionPushdown = false;
|
|
117
|
+
opts.slicePushdown = false;
|
|
118
|
+
opts.commSubplanElim = false;
|
|
119
|
+
opts.commSubexprElim = false;
|
|
120
|
+
}
|
|
121
|
+
if (opts?.streaming)
|
|
122
|
+
opts.commSubplanElim = false;
|
|
123
|
+
if (opts) {
|
|
124
|
+
_ldf = _ldf.optimizationToggle(opts.typeCoercion, opts.predicatePushdown, opts.projectionPushdown, opts.simplifyExpr, opts.slicePushdown, opts.commSubplanElim, opts.commSubexprElim, opts.streaming);
|
|
125
|
+
}
|
|
126
|
+
return (0, dataframe_1._DataFrame)(_ldf.fetchSync(numRows));
|
|
127
|
+
},
|
|
128
|
+
fetch(numRows, opts) {
|
|
129
|
+
if (opts?.noOptimization) {
|
|
130
|
+
opts.predicatePushdown = false;
|
|
131
|
+
opts.projectionPushdown = false;
|
|
132
|
+
opts.slicePushdown = false;
|
|
133
|
+
opts.commSubplanElim = false;
|
|
134
|
+
opts.commSubexprElim = false;
|
|
135
|
+
}
|
|
136
|
+
if (opts?.streaming)
|
|
137
|
+
opts.commSubplanElim = false;
|
|
138
|
+
if (opts) {
|
|
139
|
+
_ldf = _ldf.optimizationToggle(opts.typeCoercion, opts.predicatePushdown, opts.projectionPushdown, opts.simplifyExpr, opts.slicePushdown, opts.commSubplanElim, opts.commSubexprElim, opts.streaming);
|
|
140
|
+
}
|
|
141
|
+
return _ldf.fetch(numRows).then(dataframe_1._DataFrame);
|
|
142
|
+
},
|
|
143
|
+
first() {
|
|
144
|
+
return this.fetchSync(1);
|
|
145
|
+
},
|
|
146
|
+
fillNull(exprOrValue) {
|
|
147
|
+
const fillValue = (0, expr_1.exprToLitOrExpr)(exprOrValue)._expr;
|
|
148
|
+
return (0, exports._LazyDataFrame)(_ldf.fillNull(fillValue));
|
|
149
|
+
},
|
|
150
|
+
filter(exprOrValue) {
|
|
151
|
+
const predicate = (0, expr_1.exprToLitOrExpr)(exprOrValue, false)._expr;
|
|
152
|
+
return (0, exports._LazyDataFrame)(_ldf.filter(predicate));
|
|
153
|
+
},
|
|
154
|
+
groupBy(by, maintainOrder = true) {
|
|
155
|
+
if (maintainOrder?.maintainOrder !== undefined) {
|
|
156
|
+
maintainOrder = maintainOrder.maintainOrder;
|
|
157
|
+
}
|
|
158
|
+
const expr = (0, utils_1.selectionToExprList)([by], false);
|
|
159
|
+
return (0, groupby_1._LazyGroupBy)(_ldf.groupby(expr, maintainOrder));
|
|
160
|
+
},
|
|
161
|
+
groupByRolling({ indexColumn, by, period, offset, closed }) {
|
|
162
|
+
offset = offset ?? `-${period}`;
|
|
163
|
+
closed = closed ?? "right";
|
|
164
|
+
by = prepareGroupbyInputs(by);
|
|
165
|
+
const lgb = _ldf.groupbyRolling(polars_internal_1.default.col(indexColumn), period, offset, closed, by);
|
|
166
|
+
return (0, groupby_1._LazyGroupBy)(lgb);
|
|
167
|
+
},
|
|
168
|
+
groupByDynamic({ indexColumn, every, period, offset, includeBoundaries, closed, label, by, startBy, }) {
|
|
169
|
+
period = period ?? every;
|
|
170
|
+
offset = offset ?? "0ns";
|
|
171
|
+
closed = closed ?? "left";
|
|
172
|
+
label = label ?? "left";
|
|
173
|
+
by = prepareGroupbyInputs(by);
|
|
174
|
+
includeBoundaries = includeBoundaries ?? false;
|
|
175
|
+
startBy = startBy ?? "monday";
|
|
176
|
+
const lgb = _ldf.groupbyDynamic(polars_internal_1.default.col(indexColumn), every, period, offset, label, includeBoundaries, closed, by, startBy);
|
|
177
|
+
return (0, groupby_1._LazyGroupBy)(lgb);
|
|
178
|
+
},
|
|
179
|
+
head(len = 5) {
|
|
180
|
+
return (0, exports._LazyDataFrame)(_ldf.slice(0, len));
|
|
181
|
+
},
|
|
182
|
+
inner() {
|
|
183
|
+
return _ldf;
|
|
184
|
+
},
|
|
185
|
+
join(df, options) {
|
|
186
|
+
options = {
|
|
187
|
+
how: "inner",
|
|
188
|
+
suffix: "right",
|
|
189
|
+
allowParallel: true,
|
|
190
|
+
forceParallel: false,
|
|
191
|
+
...options,
|
|
192
|
+
};
|
|
193
|
+
const { how, suffix, allowParallel, forceParallel, coalesce } = options;
|
|
194
|
+
if (how === "cross") {
|
|
195
|
+
return (0, exports._LazyDataFrame)(_ldf.join(df._ldf, [], [], allowParallel, forceParallel, how, suffix, coalesce, [], []));
|
|
196
|
+
}
|
|
197
|
+
let leftOn;
|
|
198
|
+
let rightOn;
|
|
199
|
+
if (options.on) {
|
|
200
|
+
const on = (0, utils_1.selectionToExprList)(options.on, false);
|
|
201
|
+
leftOn = on;
|
|
202
|
+
rightOn = on;
|
|
203
|
+
}
|
|
204
|
+
else if ((options.leftOn && !options.rightOn) ||
|
|
205
|
+
(options.rightOn && !options.leftOn)) {
|
|
206
|
+
throw new TypeError("You should pass the column to join on as an argument.");
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
leftOn = (0, utils_1.selectionToExprList)(options.leftOn, false);
|
|
210
|
+
rightOn = (0, utils_1.selectionToExprList)(options.rightOn, false);
|
|
211
|
+
}
|
|
212
|
+
const ldf = _ldf.join(df._ldf, leftOn, rightOn, allowParallel, forceParallel, how, suffix, coalesce, [], []);
|
|
213
|
+
return (0, exports._LazyDataFrame)(ldf);
|
|
214
|
+
},
|
|
215
|
+
joinAsof(other, options) {
|
|
216
|
+
options = {
|
|
217
|
+
suffix: "_right",
|
|
218
|
+
allowParallel: true,
|
|
219
|
+
forceParallel: false,
|
|
220
|
+
strategy: "backward",
|
|
221
|
+
checkSortedness: true,
|
|
222
|
+
...options,
|
|
223
|
+
};
|
|
224
|
+
const { suffix, strategy, allowParallel, forceParallel, checkSortedness, } = options;
|
|
225
|
+
let leftOn;
|
|
226
|
+
let rightOn;
|
|
227
|
+
if (!other?._ldf) {
|
|
228
|
+
throw new TypeError("Expected a 'lazyFrame' as join table");
|
|
229
|
+
}
|
|
230
|
+
if (options.on) {
|
|
231
|
+
leftOn = rightOn = options.on;
|
|
232
|
+
}
|
|
233
|
+
else if ((options.leftOn && !options.rightOn) ||
|
|
234
|
+
(options.rightOn && !options.leftOn)) {
|
|
235
|
+
throw new TypeError("You should pass the column to join on as an argument.");
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
leftOn = options.leftOn;
|
|
239
|
+
rightOn = options.rightOn;
|
|
240
|
+
}
|
|
241
|
+
let byLeft;
|
|
242
|
+
if (typeof options.byLeft === "string") {
|
|
243
|
+
byLeft = [options.byLeft];
|
|
244
|
+
}
|
|
245
|
+
else if (Array.isArray(options.byLeft)) {
|
|
246
|
+
byLeft = options.byLeft;
|
|
247
|
+
}
|
|
248
|
+
let byRight;
|
|
249
|
+
if (typeof options.byRight === "string") {
|
|
250
|
+
byRight = [options.byRight];
|
|
251
|
+
}
|
|
252
|
+
else if (Array.isArray(options.byRight)) {
|
|
253
|
+
byRight = options.byRight;
|
|
254
|
+
}
|
|
255
|
+
if (typeof options.by === "string") {
|
|
256
|
+
byLeft = byRight = [options.by];
|
|
257
|
+
}
|
|
258
|
+
else if (Array.isArray(options.by)) {
|
|
259
|
+
byLeft = byRight = options.by;
|
|
260
|
+
}
|
|
261
|
+
let toleranceStr;
|
|
262
|
+
let toleranceNum;
|
|
263
|
+
if (typeof options.tolerance === "string") {
|
|
264
|
+
toleranceStr = options.tolerance;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
toleranceNum = options.tolerance;
|
|
268
|
+
}
|
|
269
|
+
const ldf = _ldf.joinAsof(other._ldf, polars_internal_1.default.col(leftOn), polars_internal_1.default.col(rightOn), byLeft, byRight, allowParallel, forceParallel, suffix, strategy, toleranceNum, toleranceStr, checkSortedness ?? true);
|
|
270
|
+
return (0, exports._LazyDataFrame)(ldf);
|
|
271
|
+
},
|
|
272
|
+
last() {
|
|
273
|
+
return (0, exports._LazyDataFrame)(_ldf.tail(1));
|
|
274
|
+
},
|
|
275
|
+
limit(len = 5) {
|
|
276
|
+
return (0, exports._LazyDataFrame)(_ldf.slice(0, len));
|
|
277
|
+
},
|
|
278
|
+
max() {
|
|
279
|
+
return (0, exports._LazyDataFrame)(_ldf.max());
|
|
280
|
+
},
|
|
281
|
+
mean() {
|
|
282
|
+
return (0, exports._LazyDataFrame)(_ldf.mean());
|
|
283
|
+
},
|
|
284
|
+
median() {
|
|
285
|
+
return (0, exports._LazyDataFrame)(_ldf.median());
|
|
286
|
+
},
|
|
287
|
+
melt(ids, values) {
|
|
288
|
+
return (0, exports._LazyDataFrame)(_ldf.unpivot((0, utils_1.columnOrColumnsStrict)(ids), (0, utils_1.columnOrColumnsStrict)(values)));
|
|
289
|
+
},
|
|
290
|
+
unpivot(ids, values, options) {
|
|
291
|
+
options = {
|
|
292
|
+
variableName: null,
|
|
293
|
+
valueName: null,
|
|
294
|
+
...options,
|
|
295
|
+
};
|
|
296
|
+
return (0, exports._LazyDataFrame)(_ldf.unpivot((0, utils_1.columnOrColumnsStrict)(ids), (0, utils_1.columnOrColumnsStrict)(values), options.variableName, options.valueName));
|
|
297
|
+
},
|
|
298
|
+
min() {
|
|
299
|
+
return (0, exports._LazyDataFrame)(_ldf.min());
|
|
300
|
+
},
|
|
301
|
+
quantile(quantile, interpolation = "nearest") {
|
|
302
|
+
return (0, exports._LazyDataFrame)(_ldf.quantile(quantile, interpolation));
|
|
303
|
+
},
|
|
304
|
+
rename(mapping) {
|
|
305
|
+
const existing = Object.keys(mapping);
|
|
306
|
+
const replacements = Object.values(mapping);
|
|
307
|
+
return (0, exports._LazyDataFrame)(_ldf.rename(existing, replacements));
|
|
308
|
+
},
|
|
309
|
+
reverse() {
|
|
310
|
+
return (0, exports._LazyDataFrame)(_ldf.reverse());
|
|
311
|
+
},
|
|
312
|
+
select(...exprs) {
|
|
313
|
+
const selections = (0, utils_1.selectionToExprList)(exprs, false);
|
|
314
|
+
return (0, exports._LazyDataFrame)(_ldf.select(selections));
|
|
315
|
+
},
|
|
316
|
+
shift(periods) {
|
|
317
|
+
return (0, exports._LazyDataFrame)(_ldf.shift(periods));
|
|
318
|
+
},
|
|
319
|
+
shiftAndFill(opts, fillValue) {
|
|
320
|
+
if (typeof opts === "number") {
|
|
321
|
+
return (0, exports._LazyDataFrame)(_ldf.shiftAndFill(opts, fillValue));
|
|
322
|
+
}
|
|
323
|
+
return (0, exports._LazyDataFrame)(_ldf.shiftAndFill(opts?.n, opts?.fillValue));
|
|
324
|
+
},
|
|
325
|
+
slice(opt, len) {
|
|
326
|
+
if (opt?.offset !== undefined) {
|
|
327
|
+
return (0, exports._LazyDataFrame)(_ldf.slice(opt.offset, opt.length));
|
|
328
|
+
}
|
|
329
|
+
return (0, exports._LazyDataFrame)(_ldf.slice(opt, len));
|
|
330
|
+
},
|
|
331
|
+
sort(arg, descending = false, nullsLast = false, maintainOrder = false) {
|
|
332
|
+
if (arg?.by !== undefined) {
|
|
333
|
+
return this.sort(arg.by, arg.descending, arg.nullsLast, arg.maintainOrder);
|
|
334
|
+
}
|
|
335
|
+
if (typeof arg === "string") {
|
|
336
|
+
return wrap("sort", arg, descending, nullsLast, maintainOrder);
|
|
337
|
+
}
|
|
338
|
+
const by = (0, utils_1.selectionToExprList)(arg, false);
|
|
339
|
+
return wrap("sortByExprs", by, descending, nullsLast, maintainOrder);
|
|
340
|
+
},
|
|
341
|
+
std() {
|
|
342
|
+
return (0, exports._LazyDataFrame)(_ldf.std());
|
|
343
|
+
},
|
|
344
|
+
sum() {
|
|
345
|
+
return (0, exports._LazyDataFrame)(_ldf.sum());
|
|
346
|
+
},
|
|
347
|
+
var() {
|
|
348
|
+
return (0, exports._LazyDataFrame)(_ldf.var());
|
|
349
|
+
},
|
|
350
|
+
tail(length = 5) {
|
|
351
|
+
return (0, exports._LazyDataFrame)(_ldf.tail(length));
|
|
352
|
+
},
|
|
353
|
+
toJSON(...args) {
|
|
354
|
+
// this is passed by `JSON.stringify` when calling `toJSON()`
|
|
355
|
+
if (args[0] === "") {
|
|
356
|
+
return JSON.parse(_ldf.serialize("json").toString());
|
|
357
|
+
}
|
|
358
|
+
return _ldf.serialize("json").toString();
|
|
359
|
+
},
|
|
360
|
+
serialize(format) {
|
|
361
|
+
return _ldf.serialize(format);
|
|
362
|
+
},
|
|
363
|
+
withColumn(column) {
|
|
364
|
+
return this.withColumns(column);
|
|
365
|
+
},
|
|
366
|
+
withColumns(...columns) {
|
|
367
|
+
const exprs = (0, utils_1.selectionToExprList)(columns, false);
|
|
368
|
+
return (0, exports._LazyDataFrame)(_ldf.withColumns(exprs));
|
|
369
|
+
},
|
|
370
|
+
withColumnRenamed(existing, replacement) {
|
|
371
|
+
return (0, exports._LazyDataFrame)(_ldf.rename([existing], [replacement]));
|
|
372
|
+
},
|
|
373
|
+
withRowCount(name = "row_nr") {
|
|
374
|
+
return (0, exports._LazyDataFrame)(_ldf.withRowCount(name));
|
|
375
|
+
},
|
|
376
|
+
sinkCSV(path, options) {
|
|
377
|
+
options = { ...dataframe_1.writeCsvDefaultOptions, ...options };
|
|
378
|
+
return _ldf.sinkCsv(path, options, {
|
|
379
|
+
syncOnClose: "all",
|
|
380
|
+
maintainOrder: false,
|
|
381
|
+
mkdir: true,
|
|
382
|
+
});
|
|
383
|
+
},
|
|
384
|
+
sinkParquet(path, options = {}) {
|
|
385
|
+
options.compression = options.compression ?? "zstd";
|
|
386
|
+
options.statistics = options.statistics ?? false;
|
|
387
|
+
options.sinkOptions = options.sinkOptions ?? {
|
|
388
|
+
syncOnClose: "all",
|
|
389
|
+
maintainOrder: false,
|
|
390
|
+
mkdir: true,
|
|
391
|
+
};
|
|
392
|
+
return _ldf.sinkParquet(path, options);
|
|
393
|
+
},
|
|
394
|
+
sinkNdJson(path, options = {}) {
|
|
395
|
+
options.retries = options.retries ?? 2;
|
|
396
|
+
options.syncOnClose = options.syncOnClose ?? "all";
|
|
397
|
+
options.maintainOrder = options.maintainOrder ?? true;
|
|
398
|
+
options.mkdir = options.mkdir ?? true;
|
|
399
|
+
return _ldf.sinkJson(path, options);
|
|
400
|
+
},
|
|
401
|
+
sinkIpc(path, options = {}) {
|
|
402
|
+
options.compatLevel = options.compatLevel ?? "newest";
|
|
403
|
+
options.compression = options.compression ?? "uncompressed";
|
|
404
|
+
options.retries = options.retries ?? 2;
|
|
405
|
+
options.syncOnClose = options.syncOnClose ?? "all";
|
|
406
|
+
options.maintainOrder = options.maintainOrder ?? true;
|
|
407
|
+
options.mkdir = options.mkdir ?? true;
|
|
408
|
+
return _ldf.sinkIpc(path, options);
|
|
409
|
+
},
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
exports._LazyDataFrame = _LazyDataFrame;
|
|
413
|
+
const isLazyDataFrame = (anyVal) => anyVal?.[Symbol.toStringTag] === "LazyDataFrame";
|
|
414
|
+
/** @ignore */
|
|
415
|
+
exports.LazyDataFrame = Object.assign(exports._LazyDataFrame, {
|
|
416
|
+
deserialize: (buf, fmt) => (0, exports._LazyDataFrame)(polars_internal_1.default.JsLazyFrame.deserialize(buf, fmt)),
|
|
417
|
+
fromExternal(external) {
|
|
418
|
+
return (0, exports._LazyDataFrame)(polars_internal_1.default.JsLazyFrame.cloneExternal(external));
|
|
419
|
+
},
|
|
420
|
+
isLazyDataFrame,
|
|
421
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DateFunctions } from "../../shared_traits";
|
|
2
|
+
import { type Expr } from "../expr";
|
|
3
|
+
/**
|
|
4
|
+
* DateTime functions for Lazy dataframes
|
|
5
|
+
*/
|
|
6
|
+
export interface ExprDateTime extends DateFunctions<Expr> {
|
|
7
|
+
}
|
|
8
|
+
export declare const ExprDateTimeFunctions: (_expr: any) => ExprDateTime;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExprDateTimeFunctions = void 0;
|
|
4
|
+
const expr_1 = require("../expr");
|
|
5
|
+
const ExprDateTimeFunctions = (_expr) => {
|
|
6
|
+
const wrap = (method, ...args) => {
|
|
7
|
+
return (0, expr_1._Expr)(_expr[method](...args));
|
|
8
|
+
};
|
|
9
|
+
const wrapNullArgs = (method) => () => wrap(method);
|
|
10
|
+
return {
|
|
11
|
+
day: wrapNullArgs("day"),
|
|
12
|
+
hour: wrapNullArgs("hour"),
|
|
13
|
+
minute: wrapNullArgs("minute"),
|
|
14
|
+
month: wrapNullArgs("month"),
|
|
15
|
+
nanosecond: wrapNullArgs("nanosecond"),
|
|
16
|
+
ordinalDay: wrapNullArgs("ordinalDay"),
|
|
17
|
+
second: wrapNullArgs("second"),
|
|
18
|
+
strftime: (fmt) => wrap("strftime", fmt),
|
|
19
|
+
timestamp: wrapNullArgs("timestamp"),
|
|
20
|
+
week: wrapNullArgs("week"),
|
|
21
|
+
weekday: wrapNullArgs("weekday"),
|
|
22
|
+
year: wrapNullArgs("year"),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.ExprDateTimeFunctions = ExprDateTimeFunctions;
|