@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.
- 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 +2135 -0
- package/bin/dataframe.js +783 -0
- package/bin/datatypes/conversion.d.ts +2 -0
- package/bin/datatypes/conversion.js +2 -0
- package/bin/datatypes/datatype.d.ts +285 -0
- package/bin/datatypes/datatype.js +430 -0
- package/bin/datatypes/field.d.ts +26 -0
- package/bin/datatypes/field.js +36 -0
- package/bin/datatypes/index.d.ts +43 -0
- package/bin/datatypes/index.js +120 -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 +212 -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 +256 -0
- package/bin/index.js +267 -0
- package/bin/internals/construction.d.ts +7 -0
- package/bin/internals/construction.js +256 -0
- package/bin/internals/polars_internal.d.ts +2 -0
- package/bin/internals/polars_internal.js +7 -0
- package/bin/io.d.ts +433 -0
- package/bin/io.js +344 -0
- package/bin/lazy/dataframe.d.ts +785 -0
- package/bin/lazy/dataframe.js +427 -0
- package/bin/lazy/expr/datetime.d.ts +8 -0
- package/bin/lazy/expr/datetime.js +27 -0
- package/bin/lazy/expr/index.d.ts +1152 -0
- package/bin/lazy/expr/index.js +632 -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 +612 -0
- package/bin/lazy/functions.js +687 -0
- package/bin/lazy/groupby.d.ts +29 -0
- package/bin/lazy/groupby.js +30 -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 +34 -0
- package/bin/series/index.d.ts +1135 -0
- package/bin/series/index.js +700 -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 +1458 -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 +287 -0
- package/bin/types.js +2 -0
- package/bin/utils.d.ts +38 -0
- package/bin/utils.js +69 -0
- package/package.json +45 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeUnit = exports.Struct = exports.FixedSizeList = exports.List = exports.Duration = exports.Datetime = exports.Decimal = exports.Categorical = exports.String = exports.Utf8 = exports.Object_ = exports.Time = exports.Date = exports.Float64 = exports.Float32 = exports.UInt64 = exports.UInt32 = exports.UInt16 = exports.UInt8 = exports.Int64 = exports.Int32 = exports.Int16 = exports.Int8 = exports.Bool = exports.Null = exports.DataType = void 0;
|
|
4
|
+
const field_1 = require("./field");
|
|
5
|
+
class DataType {
|
|
6
|
+
identity = "DataType";
|
|
7
|
+
get inner() {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
equals(other) {
|
|
11
|
+
return (this.variant === other.variant &&
|
|
12
|
+
this.inner === null &&
|
|
13
|
+
other.inner === null);
|
|
14
|
+
}
|
|
15
|
+
/** Null type */
|
|
16
|
+
static get Null() {
|
|
17
|
+
return new Null();
|
|
18
|
+
}
|
|
19
|
+
/** `true` and `false`. */
|
|
20
|
+
static get Bool() {
|
|
21
|
+
return new Bool();
|
|
22
|
+
}
|
|
23
|
+
/** An `i8` */
|
|
24
|
+
static get Int8() {
|
|
25
|
+
return new Int8();
|
|
26
|
+
}
|
|
27
|
+
/** An `i16` */
|
|
28
|
+
static get Int16() {
|
|
29
|
+
return new Int16();
|
|
30
|
+
}
|
|
31
|
+
/** An `i32` */
|
|
32
|
+
static get Int32() {
|
|
33
|
+
return new Int32();
|
|
34
|
+
}
|
|
35
|
+
/** An `i64` */
|
|
36
|
+
static get Int64() {
|
|
37
|
+
return new Int64();
|
|
38
|
+
}
|
|
39
|
+
/** An `u8` */
|
|
40
|
+
static get UInt8() {
|
|
41
|
+
return new UInt8();
|
|
42
|
+
}
|
|
43
|
+
/** An `u16` */
|
|
44
|
+
static get UInt16() {
|
|
45
|
+
return new UInt16();
|
|
46
|
+
}
|
|
47
|
+
/** An `u32` */
|
|
48
|
+
static get UInt32() {
|
|
49
|
+
return new UInt32();
|
|
50
|
+
}
|
|
51
|
+
/** An `u64` */
|
|
52
|
+
static get UInt64() {
|
|
53
|
+
return new UInt64();
|
|
54
|
+
}
|
|
55
|
+
/** A `f32` */
|
|
56
|
+
static get Float32() {
|
|
57
|
+
return new Float32();
|
|
58
|
+
}
|
|
59
|
+
/** A `f64` */
|
|
60
|
+
static get Float64() {
|
|
61
|
+
return new Float64();
|
|
62
|
+
}
|
|
63
|
+
static get Date() {
|
|
64
|
+
return new Date();
|
|
65
|
+
}
|
|
66
|
+
/** Time of day type */
|
|
67
|
+
static get Time() {
|
|
68
|
+
return new Time();
|
|
69
|
+
}
|
|
70
|
+
/** Type for wrapping arbitrary JS objects */
|
|
71
|
+
static get Object() {
|
|
72
|
+
return new Object_();
|
|
73
|
+
}
|
|
74
|
+
/** A categorical encoding of a set of strings */
|
|
75
|
+
static get Categorical() {
|
|
76
|
+
return new Categorical();
|
|
77
|
+
}
|
|
78
|
+
/** Decimal type */
|
|
79
|
+
static Decimal(precision, scale) {
|
|
80
|
+
return new Decimal(precision, scale);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Calendar date and time type
|
|
84
|
+
* @param timeUnit any of 'ms' | 'ns' | 'us'
|
|
85
|
+
* @param timeZone timezone string as defined by Intl.DateTimeFormat `America/New_York` for example.
|
|
86
|
+
*/
|
|
87
|
+
static Datetime(timeUnit, timeZone = null) {
|
|
88
|
+
return new Datetime(timeUnit ?? "ms", timeZone);
|
|
89
|
+
}
|
|
90
|
+
static Duration(timeUnit) {
|
|
91
|
+
return new Duration(timeUnit);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Nested list/array type
|
|
95
|
+
*
|
|
96
|
+
* @param inner The `DataType` of values within the list
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
static List(inner) {
|
|
100
|
+
return new List(inner);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* List of fixed length
|
|
104
|
+
* This is called `Array` in other polars implementations, but `Array` is widely used in JS, so we use `FixedSizeList` instead.
|
|
105
|
+
*
|
|
106
|
+
*/
|
|
107
|
+
static FixedSizeList(inner, listSize) {
|
|
108
|
+
return new FixedSizeList(inner, listSize);
|
|
109
|
+
}
|
|
110
|
+
static Struct(fields) {
|
|
111
|
+
return new Struct(fields);
|
|
112
|
+
}
|
|
113
|
+
/** A variable-length UTF-8 encoded string whose offsets are represented as `i64`. */
|
|
114
|
+
static get Utf8() {
|
|
115
|
+
return new Utf8();
|
|
116
|
+
}
|
|
117
|
+
static get String() {
|
|
118
|
+
return new String();
|
|
119
|
+
}
|
|
120
|
+
toString() {
|
|
121
|
+
if (this.inner) {
|
|
122
|
+
return `${this.identity}(${this.variant}(${this.inner}))`;
|
|
123
|
+
}
|
|
124
|
+
return `${this.identity}(${this.variant})`;
|
|
125
|
+
}
|
|
126
|
+
toJSON() {
|
|
127
|
+
const inner = this.inner;
|
|
128
|
+
if (inner) {
|
|
129
|
+
return {
|
|
130
|
+
[this.identity]: {
|
|
131
|
+
[this.variant]: inner[0],
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
[this.identity]: this.variant,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
140
|
+
return this.toString();
|
|
141
|
+
}
|
|
142
|
+
asFixedSizeList() {
|
|
143
|
+
if (this instanceof FixedSizeList) {
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.DataType = DataType;
|
|
150
|
+
class Null extends DataType {
|
|
151
|
+
variant = "Null";
|
|
152
|
+
}
|
|
153
|
+
exports.Null = Null;
|
|
154
|
+
class Bool extends DataType {
|
|
155
|
+
variant = "Bool";
|
|
156
|
+
}
|
|
157
|
+
exports.Bool = Bool;
|
|
158
|
+
class Int8 extends DataType {
|
|
159
|
+
variant = "Int8";
|
|
160
|
+
}
|
|
161
|
+
exports.Int8 = Int8;
|
|
162
|
+
class Int16 extends DataType {
|
|
163
|
+
variant = "Int16";
|
|
164
|
+
}
|
|
165
|
+
exports.Int16 = Int16;
|
|
166
|
+
class Int32 extends DataType {
|
|
167
|
+
variant = "Int32";
|
|
168
|
+
}
|
|
169
|
+
exports.Int32 = Int32;
|
|
170
|
+
class Int64 extends DataType {
|
|
171
|
+
variant = "Int64";
|
|
172
|
+
}
|
|
173
|
+
exports.Int64 = Int64;
|
|
174
|
+
class UInt8 extends DataType {
|
|
175
|
+
variant = "UInt8";
|
|
176
|
+
}
|
|
177
|
+
exports.UInt8 = UInt8;
|
|
178
|
+
class UInt16 extends DataType {
|
|
179
|
+
variant = "UInt16";
|
|
180
|
+
}
|
|
181
|
+
exports.UInt16 = UInt16;
|
|
182
|
+
class UInt32 extends DataType {
|
|
183
|
+
variant = "UInt32";
|
|
184
|
+
}
|
|
185
|
+
exports.UInt32 = UInt32;
|
|
186
|
+
class UInt64 extends DataType {
|
|
187
|
+
variant = "UInt64";
|
|
188
|
+
}
|
|
189
|
+
exports.UInt64 = UInt64;
|
|
190
|
+
class Float32 extends DataType {
|
|
191
|
+
variant = "Float32";
|
|
192
|
+
}
|
|
193
|
+
exports.Float32 = Float32;
|
|
194
|
+
class Float64 extends DataType {
|
|
195
|
+
variant = "Float64";
|
|
196
|
+
}
|
|
197
|
+
exports.Float64 = Float64;
|
|
198
|
+
// biome-ignore lint/suspicious/noShadowRestrictedNames: Using Polars Date
|
|
199
|
+
class Date extends DataType {
|
|
200
|
+
variant = "Date";
|
|
201
|
+
}
|
|
202
|
+
exports.Date = Date;
|
|
203
|
+
class Time extends DataType {
|
|
204
|
+
variant = "Time";
|
|
205
|
+
}
|
|
206
|
+
exports.Time = Time;
|
|
207
|
+
class Object_ extends DataType {
|
|
208
|
+
variant = "Object";
|
|
209
|
+
}
|
|
210
|
+
exports.Object_ = Object_;
|
|
211
|
+
class Utf8 extends DataType {
|
|
212
|
+
variant = "Utf8";
|
|
213
|
+
}
|
|
214
|
+
exports.Utf8 = Utf8;
|
|
215
|
+
// biome-ignore lint/suspicious/noShadowRestrictedNames: Using Polars String
|
|
216
|
+
class String extends DataType {
|
|
217
|
+
variant = "String";
|
|
218
|
+
}
|
|
219
|
+
exports.String = String;
|
|
220
|
+
class Categorical extends DataType {
|
|
221
|
+
variant = "Categorical";
|
|
222
|
+
}
|
|
223
|
+
exports.Categorical = Categorical;
|
|
224
|
+
class Decimal extends DataType {
|
|
225
|
+
variant = "Decimal";
|
|
226
|
+
precision;
|
|
227
|
+
scale;
|
|
228
|
+
constructor(precision, scale) {
|
|
229
|
+
super();
|
|
230
|
+
this.precision = precision ?? null;
|
|
231
|
+
this.scale = scale ?? null;
|
|
232
|
+
}
|
|
233
|
+
get inner() {
|
|
234
|
+
return [this.precision, this.scale];
|
|
235
|
+
}
|
|
236
|
+
equals(other) {
|
|
237
|
+
if (other.variant === this.variant) {
|
|
238
|
+
return (this.precision === other.precision &&
|
|
239
|
+
this.scale === other.scale);
|
|
240
|
+
}
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
toJSON() {
|
|
244
|
+
return {
|
|
245
|
+
[this.identity]: {
|
|
246
|
+
[this.variant]: {
|
|
247
|
+
precision: this.precision,
|
|
248
|
+
scale: this.scale,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
exports.Decimal = Decimal;
|
|
255
|
+
/**
|
|
256
|
+
* Datetime type
|
|
257
|
+
*/
|
|
258
|
+
class Datetime extends DataType {
|
|
259
|
+
timeUnit;
|
|
260
|
+
timeZone;
|
|
261
|
+
variant = "Datetime";
|
|
262
|
+
constructor(timeUnit = "ms", timeZone) {
|
|
263
|
+
super();
|
|
264
|
+
this.timeUnit = timeUnit;
|
|
265
|
+
this.timeZone = timeZone;
|
|
266
|
+
}
|
|
267
|
+
get inner() {
|
|
268
|
+
return [this.timeUnit, this.timeZone];
|
|
269
|
+
}
|
|
270
|
+
equals(other) {
|
|
271
|
+
if (other.variant === this.variant) {
|
|
272
|
+
return (this.timeUnit === other.timeUnit &&
|
|
273
|
+
this.timeZone === other.timeZone);
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
exports.Datetime = Datetime;
|
|
279
|
+
class Duration extends DataType {
|
|
280
|
+
timeUnit;
|
|
281
|
+
variant = "Duration";
|
|
282
|
+
constructor(timeUnit = "ms") {
|
|
283
|
+
super();
|
|
284
|
+
this.timeUnit = timeUnit;
|
|
285
|
+
}
|
|
286
|
+
get inner() {
|
|
287
|
+
return [this.timeUnit];
|
|
288
|
+
}
|
|
289
|
+
equals(other) {
|
|
290
|
+
if (other.variant === this.variant) {
|
|
291
|
+
return this.timeUnit === other.timeUnit;
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
exports.Duration = Duration;
|
|
297
|
+
class List extends DataType {
|
|
298
|
+
__inner;
|
|
299
|
+
variant = "List";
|
|
300
|
+
constructor(__inner) {
|
|
301
|
+
super();
|
|
302
|
+
this.__inner = __inner;
|
|
303
|
+
}
|
|
304
|
+
get inner() {
|
|
305
|
+
return [this.__inner];
|
|
306
|
+
}
|
|
307
|
+
equals(other) {
|
|
308
|
+
if (other.variant === this.variant) {
|
|
309
|
+
return this.inner[0].equals(other.inner[0]);
|
|
310
|
+
}
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
exports.List = List;
|
|
315
|
+
class FixedSizeList extends DataType {
|
|
316
|
+
__inner;
|
|
317
|
+
listSize;
|
|
318
|
+
variant = "FixedSizeList";
|
|
319
|
+
constructor(__inner, listSize) {
|
|
320
|
+
super();
|
|
321
|
+
this.__inner = __inner;
|
|
322
|
+
this.listSize = listSize;
|
|
323
|
+
}
|
|
324
|
+
get inner() {
|
|
325
|
+
return [this.__inner, this.listSize];
|
|
326
|
+
}
|
|
327
|
+
equals(other) {
|
|
328
|
+
if (other.variant === this.variant) {
|
|
329
|
+
return (this.inner[0].equals(other.inner[0]) &&
|
|
330
|
+
this.inner[1] === other.inner[1]);
|
|
331
|
+
}
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
toJSON() {
|
|
335
|
+
return {
|
|
336
|
+
[this.identity]: {
|
|
337
|
+
[this.variant]: {
|
|
338
|
+
type: this.inner[0].toJSON(),
|
|
339
|
+
size: this.inner[1],
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
exports.FixedSizeList = FixedSizeList;
|
|
346
|
+
class Struct extends DataType {
|
|
347
|
+
variant = "Struct";
|
|
348
|
+
fields;
|
|
349
|
+
constructor(inner) {
|
|
350
|
+
super();
|
|
351
|
+
if (Array.isArray(inner)) {
|
|
352
|
+
this.fields = inner;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
this.fields = Object.entries(inner).map(field_1.Field.from);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
get inner() {
|
|
359
|
+
return this.fields;
|
|
360
|
+
}
|
|
361
|
+
equals(other) {
|
|
362
|
+
if (other.variant === this.variant) {
|
|
363
|
+
return this.inner
|
|
364
|
+
.map((fld, idx) => {
|
|
365
|
+
const otherfld = other.fields[idx];
|
|
366
|
+
return otherfld.name === fld.name && otherfld.dtype.equals(fld.dtype);
|
|
367
|
+
})
|
|
368
|
+
.every((value) => value);
|
|
369
|
+
}
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
toJSON() {
|
|
373
|
+
return {
|
|
374
|
+
[this.identity]: {
|
|
375
|
+
[this.variant]: this.fields,
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
exports.Struct = Struct;
|
|
381
|
+
/**
|
|
382
|
+
* Datetime time unit
|
|
383
|
+
*/
|
|
384
|
+
var TimeUnit;
|
|
385
|
+
(function (TimeUnit) {
|
|
386
|
+
TimeUnit["Nanoseconds"] = "ns";
|
|
387
|
+
TimeUnit["Microseconds"] = "us";
|
|
388
|
+
TimeUnit["Milliseconds"] = "ms";
|
|
389
|
+
})(TimeUnit || (exports.TimeUnit = TimeUnit = {}));
|
|
390
|
+
/**
|
|
391
|
+
* @ignore
|
|
392
|
+
* Timeunit namespace
|
|
393
|
+
*/
|
|
394
|
+
(function (TimeUnit) {
|
|
395
|
+
function from(s) {
|
|
396
|
+
return TimeUnit[s];
|
|
397
|
+
}
|
|
398
|
+
TimeUnit.from = from;
|
|
399
|
+
})(TimeUnit || (exports.TimeUnit = TimeUnit = {}));
|
|
400
|
+
/**
|
|
401
|
+
* Datatype namespace
|
|
402
|
+
*/
|
|
403
|
+
(function (DataType) {
|
|
404
|
+
/**
|
|
405
|
+
* deserializes a datatype from the serde output of rust polars `DataType`
|
|
406
|
+
* @param dtype dtype object
|
|
407
|
+
*/
|
|
408
|
+
function deserialize(dtype) {
|
|
409
|
+
if (typeof dtype === "string") {
|
|
410
|
+
const member = DataType[dtype];
|
|
411
|
+
// if it's a factory function, call it with no args (use defaults),
|
|
412
|
+
// otherwise return the already-instantiated value
|
|
413
|
+
return typeof member === "function" ? member() : member;
|
|
414
|
+
}
|
|
415
|
+
let { variant, inner } = dtype;
|
|
416
|
+
if (variant === "Struct") {
|
|
417
|
+
inner = [
|
|
418
|
+
inner[0].map((fld) => field_1.Field.from(fld.name, deserialize(fld.dtype))),
|
|
419
|
+
];
|
|
420
|
+
}
|
|
421
|
+
if (variant === "List") {
|
|
422
|
+
inner = [deserialize(inner[0])];
|
|
423
|
+
}
|
|
424
|
+
if (variant === "FixedSizeList") {
|
|
425
|
+
inner = [deserialize(inner[0]), inner[1]];
|
|
426
|
+
}
|
|
427
|
+
return DataType[variant](...inner);
|
|
428
|
+
}
|
|
429
|
+
DataType.deserialize = deserialize;
|
|
430
|
+
})(DataType || (exports.DataType = DataType = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DataType } from "./datatype";
|
|
2
|
+
/**
|
|
3
|
+
* A field is a name and a datatype.
|
|
4
|
+
*/
|
|
5
|
+
export interface iField {
|
|
6
|
+
name: string;
|
|
7
|
+
dtype: DataType;
|
|
8
|
+
}
|
|
9
|
+
export declare class Field implements iField {
|
|
10
|
+
name: string;
|
|
11
|
+
dtype: DataType;
|
|
12
|
+
constructor(name: string, dtype: DataType);
|
|
13
|
+
toString(): string;
|
|
14
|
+
toJSON(): {
|
|
15
|
+
name: string;
|
|
16
|
+
dtype: DataType<any>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare namespace Field {
|
|
20
|
+
function from(name: string, dtype: DataType): Field;
|
|
21
|
+
function from([string, DataType]: [any, any]): Field;
|
|
22
|
+
function from(obj: {
|
|
23
|
+
name: string;
|
|
24
|
+
dtype: DataType;
|
|
25
|
+
}): Field;
|
|
26
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Field = void 0;
|
|
4
|
+
class Field {
|
|
5
|
+
name;
|
|
6
|
+
dtype;
|
|
7
|
+
constructor(name, dtype) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.dtype = dtype;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `Field("${this.name}", ${this.dtype})`;
|
|
13
|
+
}
|
|
14
|
+
toJSON() {
|
|
15
|
+
return {
|
|
16
|
+
name: this.name,
|
|
17
|
+
dtype: this.dtype,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
21
|
+
return this.toJSON();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Field = Field;
|
|
25
|
+
(function (Field) {
|
|
26
|
+
function from(nameOrObj, dtype) {
|
|
27
|
+
if (typeof nameOrObj === "string" && dtype) {
|
|
28
|
+
return new Field(nameOrObj, dtype);
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(nameOrObj)) {
|
|
31
|
+
return new Field(nameOrObj[0], nameOrObj[1]);
|
|
32
|
+
}
|
|
33
|
+
return new Field(nameOrObj.name, nameOrObj.dtype);
|
|
34
|
+
}
|
|
35
|
+
Field.from = from;
|
|
36
|
+
})(Field || (exports.Field = Field = {}));
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export * from "./conversion";
|
|
2
|
+
export * from "./datatype";
|
|
3
|
+
export { Field } from "./field";
|
|
4
|
+
import { type DataType } from "./datatype";
|
|
5
|
+
/** @ignore */
|
|
6
|
+
export type TypedArray = Int8Array | Int16Array | Int32Array | BigInt64Array | Uint8Array | Uint16Array | Uint32Array | BigInt64Array | Float32Array | Float64Array;
|
|
7
|
+
/**
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
export type Optional<T> = T | undefined | null;
|
|
11
|
+
/**
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
export type JsDataFrame = any;
|
|
15
|
+
export type NullValues = string | Array<string> | Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* @ignore
|
|
18
|
+
*/
|
|
19
|
+
export declare const DTYPE_TO_FFINAME: {
|
|
20
|
+
Int8: string;
|
|
21
|
+
Int16: string;
|
|
22
|
+
Int32: string;
|
|
23
|
+
Int64: string;
|
|
24
|
+
UInt8: string;
|
|
25
|
+
UInt16: string;
|
|
26
|
+
UInt32: string;
|
|
27
|
+
UInt64: string;
|
|
28
|
+
Float32: string;
|
|
29
|
+
Float64: string;
|
|
30
|
+
Bool: string;
|
|
31
|
+
Utf8: string;
|
|
32
|
+
String: string;
|
|
33
|
+
List: string;
|
|
34
|
+
Date: string;
|
|
35
|
+
Datetime: string;
|
|
36
|
+
Duration: string;
|
|
37
|
+
Time: string;
|
|
38
|
+
Object: string;
|
|
39
|
+
Categorical: string;
|
|
40
|
+
Struct: string;
|
|
41
|
+
};
|
|
42
|
+
/** @ignore */
|
|
43
|
+
export declare const polarsTypeToConstructor: (dtype: DataType) => CallableFunction;
|
|
@@ -0,0 +1,120 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.polarsTypeToConstructor = exports.DTYPE_TO_FFINAME = exports.Field = void 0;
|
|
21
|
+
__exportStar(require("./conversion"), exports);
|
|
22
|
+
__exportStar(require("./datatype"), exports);
|
|
23
|
+
var field_1 = require("./field");
|
|
24
|
+
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return field_1.Field; } });
|
|
25
|
+
const polars_internal_1 = __importDefault(require("../internals/polars_internal"));
|
|
26
|
+
const datatype_1 = require("./datatype");
|
|
27
|
+
/**
|
|
28
|
+
* @ignore
|
|
29
|
+
*/
|
|
30
|
+
exports.DTYPE_TO_FFINAME = {
|
|
31
|
+
Int8: "I8",
|
|
32
|
+
Int16: "I16",
|
|
33
|
+
Int32: "I32",
|
|
34
|
+
Int64: "I64",
|
|
35
|
+
UInt8: "U8",
|
|
36
|
+
UInt16: "U16",
|
|
37
|
+
UInt32: "U32",
|
|
38
|
+
UInt64: "U64",
|
|
39
|
+
Float32: "F32",
|
|
40
|
+
Float64: "F64",
|
|
41
|
+
Bool: "Bool",
|
|
42
|
+
Utf8: "Str",
|
|
43
|
+
String: "Str",
|
|
44
|
+
List: "List",
|
|
45
|
+
Date: "Date",
|
|
46
|
+
Datetime: "Datetime",
|
|
47
|
+
Duration: "Duration",
|
|
48
|
+
Time: "Time",
|
|
49
|
+
Object: "Object",
|
|
50
|
+
Categorical: "Categorical",
|
|
51
|
+
Struct: "Struct",
|
|
52
|
+
};
|
|
53
|
+
const POLARS_TYPE_TO_CONSTRUCTOR = {
|
|
54
|
+
Float32(name, values) {
|
|
55
|
+
return polars_internal_1.default.JsSeries.newOptF64(name, values);
|
|
56
|
+
},
|
|
57
|
+
Float64(name, values) {
|
|
58
|
+
return polars_internal_1.default.JsSeries.newOptF64(name, values);
|
|
59
|
+
},
|
|
60
|
+
Int8(name, values) {
|
|
61
|
+
return polars_internal_1.default.JsSeries.newOptI32(name, values);
|
|
62
|
+
},
|
|
63
|
+
Int16(name, values) {
|
|
64
|
+
return polars_internal_1.default.JsSeries.newOptI32(name, values);
|
|
65
|
+
},
|
|
66
|
+
Int32(name, values) {
|
|
67
|
+
return polars_internal_1.default.JsSeries.newOptI32(name, values);
|
|
68
|
+
},
|
|
69
|
+
Int64(name, values) {
|
|
70
|
+
return polars_internal_1.default.JsSeries.newOptI64(name, values);
|
|
71
|
+
},
|
|
72
|
+
UInt8(name, values) {
|
|
73
|
+
return polars_internal_1.default.JsSeries.newOptU32(name, values);
|
|
74
|
+
},
|
|
75
|
+
UInt16(name, values) {
|
|
76
|
+
return polars_internal_1.default.JsSeries.newOptU32(name, values);
|
|
77
|
+
},
|
|
78
|
+
UInt32(name, values) {
|
|
79
|
+
return polars_internal_1.default.JsSeries.newOptU32(name, values);
|
|
80
|
+
},
|
|
81
|
+
UInt64(name, values) {
|
|
82
|
+
return polars_internal_1.default.JsSeries.newOptU64(name, values);
|
|
83
|
+
},
|
|
84
|
+
Date(name, values) {
|
|
85
|
+
return polars_internal_1.default.JsSeries.newOptI64(name, values);
|
|
86
|
+
},
|
|
87
|
+
Datetime(name, values) {
|
|
88
|
+
return polars_internal_1.default.JsSeries.newOptI64(name, values);
|
|
89
|
+
},
|
|
90
|
+
Time(name, values) {
|
|
91
|
+
return polars_internal_1.default.JsSeries.newAnyValue(name, values, datatype_1.Time);
|
|
92
|
+
},
|
|
93
|
+
Bool(name, values) {
|
|
94
|
+
return polars_internal_1.default.JsSeries.newOptBool(name, values);
|
|
95
|
+
},
|
|
96
|
+
Utf8(name, values) {
|
|
97
|
+
return polars_internal_1.default.JsSeries.newOptStr(name, values);
|
|
98
|
+
},
|
|
99
|
+
String(name, values) {
|
|
100
|
+
return polars_internal_1.default.JsSeries.newOptStr(name, values);
|
|
101
|
+
},
|
|
102
|
+
Categorical(name, values) {
|
|
103
|
+
return polars_internal_1.default.JsSeries.newOptStr(name, values);
|
|
104
|
+
},
|
|
105
|
+
List(name, values, dtype) {
|
|
106
|
+
return polars_internal_1.default.JsSeries.newList(name, values, dtype);
|
|
107
|
+
},
|
|
108
|
+
FixedSizeList(name, values, dtype) {
|
|
109
|
+
return polars_internal_1.default.JsSeries.newList(name, values, dtype);
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
/** @ignore */
|
|
113
|
+
const polarsTypeToConstructor = (dtype) => {
|
|
114
|
+
const ctor = POLARS_TYPE_TO_CONSTRUCTOR[dtype.variant];
|
|
115
|
+
if (!ctor) {
|
|
116
|
+
throw new Error(`Cannot construct Series for type ${dtype.variant}.`);
|
|
117
|
+
}
|
|
118
|
+
return ctor;
|
|
119
|
+
};
|
|
120
|
+
exports.polarsTypeToConstructor = polarsTypeToConstructor;
|
package/bin/error.d.ts
ADDED
package/bin/error.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.todo = exports.NotImplemented = exports.InvalidOperationError = void 0;
|
|
4
|
+
class InvalidOperationError extends RangeError {
|
|
5
|
+
constructor(method, dtype) {
|
|
6
|
+
super(`Invalid operation: ${method} is not supported for ${dtype}`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.InvalidOperationError = InvalidOperationError;
|
|
10
|
+
class NotImplemented extends Error {
|
|
11
|
+
constructor(method, dtype) {
|
|
12
|
+
super(`Invalid operation: ${method} is not supported for ${dtype}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.NotImplemented = NotImplemented;
|
|
16
|
+
const todo = () => new Error("not yet implemented");
|
|
17
|
+
exports.todo = todo;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type DataFrame } from "./dataframe";
|
|
2
|
+
import { type LazyDataFrame } from "./lazy/dataframe";
|
|
3
|
+
import { type Series } from "./series";
|
|
4
|
+
import type { ConcatOptions } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* _Repeat a single value n times and collect into a Series._
|
|
7
|
+
* @param value - Value to repeat.
|
|
8
|
+
* @param n - Number of repeats
|
|
9
|
+
* @param name - Optional name of the Series
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* > const s = pl.repeat("a", 5)
|
|
15
|
+
* > s.toArray()
|
|
16
|
+
* ["a", "a", "a", "a", "a"]
|
|
17
|
+
*
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function repeat<V>(value: V, n: number, name?: string): Series;
|
|
21
|
+
export declare function concat(items: Array<DataFrame>, options?: ConcatOptions): DataFrame;
|
|
22
|
+
export declare function concat(items: Array<Series>, options?: {
|
|
23
|
+
rechunk: boolean;
|
|
24
|
+
parallel: boolean;
|
|
25
|
+
}): Series;
|
|
26
|
+
export declare function concat(items: Array<LazyDataFrame>, options?: ConcatOptions): LazyDataFrame;
|