@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,29 @@
|
|
|
1
|
+
import { type LazyDataFrame } from "./dataframe";
|
|
2
|
+
import type { Expr } from "./expr";
|
|
3
|
+
/** @ignore */
|
|
4
|
+
export declare const _LazyGroupBy: (_lgb: any) => LazyGroupBy;
|
|
5
|
+
/**
|
|
6
|
+
* LazyGroupBy
|
|
7
|
+
* @category lazy
|
|
8
|
+
*/
|
|
9
|
+
export interface LazyGroupBy {
|
|
10
|
+
/**
|
|
11
|
+
* Aggregate the groupby.
|
|
12
|
+
*/
|
|
13
|
+
agg(...aggs: Expr[]): LazyDataFrame;
|
|
14
|
+
/**
|
|
15
|
+
* Return the first n rows of the groupby.
|
|
16
|
+
* @param n number of rows to return
|
|
17
|
+
*/
|
|
18
|
+
head(n?: number): LazyDataFrame;
|
|
19
|
+
/**
|
|
20
|
+
* Return the number of rows in each group.
|
|
21
|
+
* @param name Assign a name to the resulting column; if unset, defaults to "len".
|
|
22
|
+
*/
|
|
23
|
+
len(name?: string): LazyDataFrame;
|
|
24
|
+
/**
|
|
25
|
+
* Return the last n rows of the groupby.
|
|
26
|
+
* @param n number of rows to return
|
|
27
|
+
*/
|
|
28
|
+
tail(n?: number): LazyDataFrame;
|
|
29
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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._LazyGroupBy = void 0;
|
|
7
|
+
const polars_internal_1 = __importDefault(require("../internals/polars_internal"));
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const dataframe_1 = require("./dataframe");
|
|
10
|
+
/** @ignore */
|
|
11
|
+
const _LazyGroupBy = (_lgb) => {
|
|
12
|
+
return {
|
|
13
|
+
agg(...aggs) {
|
|
14
|
+
aggs = (0, utils_1.selectionToExprList)(aggs, false);
|
|
15
|
+
const ret = _lgb.agg(aggs.flat());
|
|
16
|
+
return (0, dataframe_1._LazyDataFrame)(ret);
|
|
17
|
+
},
|
|
18
|
+
head(n = 5) {
|
|
19
|
+
return (0, dataframe_1._LazyDataFrame)(_lgb.head(n));
|
|
20
|
+
},
|
|
21
|
+
len(name) {
|
|
22
|
+
const expr = name ? polars_internal_1.default.len().alias(name) : polars_internal_1.default.len();
|
|
23
|
+
return (0, dataframe_1._LazyDataFrame)(_lgb.agg([expr]));
|
|
24
|
+
},
|
|
25
|
+
tail(n = 5) {
|
|
26
|
+
return (0, dataframe_1._LazyDataFrame)(_lgb.tail(n));
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
exports._LazyGroupBy = _LazyGroupBy;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./expr"), exports);
|
|
18
|
+
__exportStar(require("./functions"), exports);
|
|
19
|
+
__exportStar(require("./groupby"), exports);
|
|
20
|
+
__exportStar(require("./whenthen"), exports);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Expr } from "./expr";
|
|
2
|
+
export interface When {
|
|
3
|
+
/** Values to return in case of the predicate being `true`.*/
|
|
4
|
+
then(expr: Expr): Then;
|
|
5
|
+
}
|
|
6
|
+
export interface Then {
|
|
7
|
+
/** Start another when, then, otherwise layer. */
|
|
8
|
+
when(predicate: Expr): ChainedWhen;
|
|
9
|
+
/** Values to return in case of the predicate being `false`. */
|
|
10
|
+
otherwise(expr: Expr): Expr;
|
|
11
|
+
}
|
|
12
|
+
export interface ChainedWhen {
|
|
13
|
+
/** Values to return in case of the predicate being `true`. */
|
|
14
|
+
then(expr: Expr): ChainedThen;
|
|
15
|
+
}
|
|
16
|
+
export interface ChainedThen {
|
|
17
|
+
/** Start another when, then, otherwise layer. */
|
|
18
|
+
when(predicate: Expr): ChainedWhen;
|
|
19
|
+
/** Values to return in case of the predicate being `true`. */
|
|
20
|
+
then(expr: Expr): ChainedThen;
|
|
21
|
+
/** Values to return in case of the predicate being `false`. */
|
|
22
|
+
otherwise(expr: Expr): Expr;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Start a when, then, otherwise expression.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```
|
|
29
|
+
* // Below we add a column with the value 1, where column "foo" > 2 and the value -1 where it isn't.
|
|
30
|
+
* > df = pl.DataFrame({"foo": [1, 3, 4], "bar": [3, 4, 0]})
|
|
31
|
+
* > df.withColumn(pl.when(pl.col("foo").gt(2)).then(pl.lit(1)).otherwise(pl.lit(-1)))
|
|
32
|
+
* shape: (3, 3)
|
|
33
|
+
* ┌─────┬─────┬─────────┐
|
|
34
|
+
* │ foo ┆ bar ┆ literal │
|
|
35
|
+
* │ --- ┆ --- ┆ --- │
|
|
36
|
+
* │ i64 ┆ i64 ┆ i32 │
|
|
37
|
+
* ╞═════╪═════╪═════════╡
|
|
38
|
+
* │ 1 ┆ 3 ┆ -1 │
|
|
39
|
+
* ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
|
|
40
|
+
* │ 3 ┆ 4 ┆ 1 │
|
|
41
|
+
* ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
|
|
42
|
+
* │ 4 ┆ 0 ┆ 1 │
|
|
43
|
+
* └─────┴─────┴─────────┘
|
|
44
|
+
*
|
|
45
|
+
* // Or with multiple `when, thens` chained:
|
|
46
|
+
* > df.with_column(
|
|
47
|
+
* ... pl.when(pl.col("foo").gt(2))
|
|
48
|
+
* ... .then(1)
|
|
49
|
+
* ... .when(pl.col("bar").gt(2))
|
|
50
|
+
* ... .then(4)
|
|
51
|
+
* ... .otherwise(-1)
|
|
52
|
+
* ... )
|
|
53
|
+
* shape: (3, 3)
|
|
54
|
+
* ┌─────┬─────┬─────────┐
|
|
55
|
+
* │ foo ┆ bar ┆ literal │
|
|
56
|
+
* │ --- ┆ --- ┆ --- │
|
|
57
|
+
* │ i64 ┆ i64 ┆ i32 │
|
|
58
|
+
* ╞═════╪═════╪═════════╡
|
|
59
|
+
* │ 1 ┆ 3 ┆ 4 │
|
|
60
|
+
* ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
|
|
61
|
+
* │ 3 ┆ 4 ┆ 1 │
|
|
62
|
+
* ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
|
|
63
|
+
* │ 4 ┆ 0 ┆ 1 │
|
|
64
|
+
* └─────┴─────┴─────────┘
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function when(expr: Expr): When;
|
|
@@ -0,0 +1,81 @@
|
|
|
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.when = when;
|
|
7
|
+
const polars_internal_1 = __importDefault(require("../internals/polars_internal"));
|
|
8
|
+
const expr_1 = require("./expr");
|
|
9
|
+
function ChainedWhen(_chainedwhen) {
|
|
10
|
+
return {
|
|
11
|
+
then: ({ _expr }) => ChainedThen(_chainedwhen.then(_expr)),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function ChainedThen(_chainedthen) {
|
|
15
|
+
return {
|
|
16
|
+
when: ({ _expr }) => ChainedWhen(_chainedthen.when(_expr)),
|
|
17
|
+
then: ({ _expr }) => ChainedThen(_chainedthen.then(_expr)),
|
|
18
|
+
otherwise: ({ _expr }) => expr_1.Expr(_chainedthen.otherwise(_expr)),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function Then(_then) {
|
|
22
|
+
return {
|
|
23
|
+
when: ({ _expr }) => ChainedWhen(_then.when(_expr)),
|
|
24
|
+
otherwise: ({ _expr }) => expr_1.Expr(_then.otherwise(_expr)),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Utility function.
|
|
29
|
+
* @see {@link when}
|
|
30
|
+
*/
|
|
31
|
+
function When(_when) {
|
|
32
|
+
return {
|
|
33
|
+
then: ({ _expr }) => Then(_when.then(_expr)),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Start a when, then, otherwise expression.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```
|
|
41
|
+
* // Below we add a column with the value 1, where column "foo" > 2 and the value -1 where it isn't.
|
|
42
|
+
* > df = pl.DataFrame({"foo": [1, 3, 4], "bar": [3, 4, 0]})
|
|
43
|
+
* > df.withColumn(pl.when(pl.col("foo").gt(2)).then(pl.lit(1)).otherwise(pl.lit(-1)))
|
|
44
|
+
* shape: (3, 3)
|
|
45
|
+
* ┌─────┬─────┬─────────┐
|
|
46
|
+
* │ foo ┆ bar ┆ literal │
|
|
47
|
+
* │ --- ┆ --- ┆ --- │
|
|
48
|
+
* │ i64 ┆ i64 ┆ i32 │
|
|
49
|
+
* ╞═════╪═════╪═════════╡
|
|
50
|
+
* │ 1 ┆ 3 ┆ -1 │
|
|
51
|
+
* ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
|
|
52
|
+
* │ 3 ┆ 4 ┆ 1 │
|
|
53
|
+
* ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
|
|
54
|
+
* │ 4 ┆ 0 ┆ 1 │
|
|
55
|
+
* └─────┴─────┴─────────┘
|
|
56
|
+
*
|
|
57
|
+
* // Or with multiple `when, thens` chained:
|
|
58
|
+
* > df.with_column(
|
|
59
|
+
* ... pl.when(pl.col("foo").gt(2))
|
|
60
|
+
* ... .then(1)
|
|
61
|
+
* ... .when(pl.col("bar").gt(2))
|
|
62
|
+
* ... .then(4)
|
|
63
|
+
* ... .otherwise(-1)
|
|
64
|
+
* ... )
|
|
65
|
+
* shape: (3, 3)
|
|
66
|
+
* ┌─────┬─────┬─────────┐
|
|
67
|
+
* │ foo ┆ bar ┆ literal │
|
|
68
|
+
* │ --- ┆ --- ┆ --- │
|
|
69
|
+
* │ i64 ┆ i64 ┆ i32 │
|
|
70
|
+
* ╞═════╪═════╪═════════╡
|
|
71
|
+
* │ 1 ┆ 3 ┆ 4 │
|
|
72
|
+
* ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
|
|
73
|
+
* │ 3 ┆ 4 ┆ 1 │
|
|
74
|
+
* ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
|
|
75
|
+
* │ 4 ┆ 0 ┆ 1 │
|
|
76
|
+
* └─────┴─────┴─────────┘
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
function when(expr) {
|
|
80
|
+
return When(polars_internal_1.default.when(expr._expr));
|
|
81
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { existsSync, readFileSync } = require('fs');
|
|
3
|
+
const { join } = require('path');
|
|
4
|
+
const { platform, arch } = process;
|
|
5
|
+
let nativeBinding = null;
|
|
6
|
+
let localFileExisted = false;
|
|
7
|
+
let loadError = null;
|
|
8
|
+
function isMusl() {
|
|
9
|
+
// For Node 10
|
|
10
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
11
|
+
try {
|
|
12
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim();
|
|
13
|
+
return readFileSync(lddPath, 'utf8').includes('musl');
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const { glibcVersionRuntime } = process.report.getReport().header;
|
|
21
|
+
return !glibcVersionRuntime;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
switch (platform) {
|
|
25
|
+
case 'android':
|
|
26
|
+
switch (arch) {
|
|
27
|
+
case 'arm64':
|
|
28
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.android-arm64.node'));
|
|
29
|
+
try {
|
|
30
|
+
if (localFileExisted) {
|
|
31
|
+
nativeBinding = require('./nodejs-polars.android-arm64.node');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
nativeBinding = require('nodejs-polars-android-arm64');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
loadError = e;
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
case 'arm':
|
|
42
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.android-arm-eabi.node'));
|
|
43
|
+
try {
|
|
44
|
+
if (localFileExisted) {
|
|
45
|
+
nativeBinding = require('./nodejs-polars.android-arm-eabi.node');
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
nativeBinding = require('nodejs-polars-android-arm-eabi');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
loadError = e;
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
throw new Error(`Unsupported architecture on Android ${arch}`);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case 'win32':
|
|
60
|
+
switch (arch) {
|
|
61
|
+
case 'x64':
|
|
62
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.win32-x64-msvc.node'));
|
|
63
|
+
try {
|
|
64
|
+
if (localFileExisted) {
|
|
65
|
+
nativeBinding = require('./nodejs-polars.win32-x64-msvc.node');
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
nativeBinding = require('nodejs-polars-win32-x64-msvc');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
loadError = e;
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
case 'ia32':
|
|
76
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.win32-ia32-msvc.node'));
|
|
77
|
+
try {
|
|
78
|
+
if (localFileExisted) {
|
|
79
|
+
nativeBinding = require('./nodejs-polars.win32-ia32-msvc.node');
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
nativeBinding = require('nodejs-polars-win32-ia32-msvc');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
loadError = e;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case 'arm64':
|
|
90
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.win32-arm64-msvc.node'));
|
|
91
|
+
try {
|
|
92
|
+
if (localFileExisted) {
|
|
93
|
+
nativeBinding = require('./nodejs-polars.win32-arm64-msvc.node');
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
nativeBinding = require('nodejs-polars-win32-arm64-msvc');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
loadError = e;
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`);
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case 'darwin':
|
|
108
|
+
switch (arch) {
|
|
109
|
+
case 'x64':
|
|
110
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.darwin-x64.node'));
|
|
111
|
+
try {
|
|
112
|
+
if (localFileExisted) {
|
|
113
|
+
nativeBinding = require('./nodejs-polars.darwin-x64.node');
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
nativeBinding = require('nodejs-polars-darwin-x64');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
loadError = e;
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
case 'arm64':
|
|
124
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.darwin-arm64.node'));
|
|
125
|
+
try {
|
|
126
|
+
if (localFileExisted) {
|
|
127
|
+
nativeBinding = require('./nodejs-polars.darwin-arm64.node');
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
nativeBinding = require('nodejs-polars-darwin-arm64');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
loadError = e;
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`);
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
case 'freebsd':
|
|
142
|
+
if (arch !== 'x64') {
|
|
143
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
|
|
144
|
+
}
|
|
145
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.freebsd-x64.node'));
|
|
146
|
+
try {
|
|
147
|
+
if (localFileExisted) {
|
|
148
|
+
nativeBinding = require('./nodejs-polars.freebsd-x64.node');
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
nativeBinding = require('nodejs-polars-freebsd-x64');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
loadError = e;
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case 'linux':
|
|
159
|
+
switch (arch) {
|
|
160
|
+
case 'x64':
|
|
161
|
+
if (isMusl()) {
|
|
162
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.linux-x64-musl.node'));
|
|
163
|
+
try {
|
|
164
|
+
if (localFileExisted) {
|
|
165
|
+
nativeBinding = require('./nodejs-polars.linux-x64-musl.node');
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
nativeBinding = require('nodejs-polars-linux-x64-musl');
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
loadError = e;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.linux-x64-gnu.node'));
|
|
177
|
+
try {
|
|
178
|
+
if (localFileExisted) {
|
|
179
|
+
nativeBinding = require('./nodejs-polars.linux-x64-gnu.node');
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
nativeBinding = require('nodejs-polars-linux-x64-gnu');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
loadError = e;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
case 'arm64':
|
|
191
|
+
if (isMusl()) {
|
|
192
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.linux-arm64-musl.node'));
|
|
193
|
+
try {
|
|
194
|
+
if (localFileExisted) {
|
|
195
|
+
nativeBinding = require('./nodejs-polars.linux-arm64-musl.node');
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
nativeBinding = require('nodejs-polars-linux-arm64-musl');
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
loadError = e;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.linux-arm64-gnu.node'));
|
|
207
|
+
try {
|
|
208
|
+
if (localFileExisted) {
|
|
209
|
+
nativeBinding = require('./nodejs-polars.linux-arm64-gnu.node');
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
nativeBinding = require('nodejs-polars-linux-arm64-gnu');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch (e) {
|
|
216
|
+
loadError = e;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
case 'arm':
|
|
221
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.linux-arm-gnueabihf.node'));
|
|
222
|
+
try {
|
|
223
|
+
if (localFileExisted) {
|
|
224
|
+
nativeBinding = require('./nodejs-polars.linux-arm-gnueabihf.node');
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
nativeBinding = require('nodejs-polars-linux-arm-gnueabihf');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch (e) {
|
|
231
|
+
loadError = e;
|
|
232
|
+
}
|
|
233
|
+
break;
|
|
234
|
+
default:
|
|
235
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`);
|
|
236
|
+
}
|
|
237
|
+
break;
|
|
238
|
+
case 'openharmony':
|
|
239
|
+
switch (arch) {
|
|
240
|
+
case 'arm64':
|
|
241
|
+
localFileExisted = existsSync(join(__dirname, 'nodejs-polars.openharmony-arm64.node'));
|
|
242
|
+
try {
|
|
243
|
+
if (localFileExisted) {
|
|
244
|
+
nativeBinding = require('./nodejs-polars.openharmony-arm64.node');
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
nativeBinding = require('@ohos-ports/nodejs-polars-openharmony-arm64');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
loadError = e;
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
default:
|
|
255
|
+
throw new Error(`Unsupported architecture on openharmony: ${arch}`);
|
|
256
|
+
}
|
|
257
|
+
break;
|
|
258
|
+
default:
|
|
259
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
|
|
260
|
+
}
|
|
261
|
+
if (!nativeBinding) {
|
|
262
|
+
if (loadError) {
|
|
263
|
+
throw loadError;
|
|
264
|
+
}
|
|
265
|
+
throw new Error(`Failed to load native binding`);
|
|
266
|
+
}
|
|
267
|
+
module.exports = nativeBinding;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DateFunctions } from "../shared_traits";
|
|
2
|
+
import { type Series } from ".";
|
|
3
|
+
/**
|
|
4
|
+
* DateTime functions for Series
|
|
5
|
+
*/
|
|
6
|
+
export interface SeriesDateFunctions extends DateFunctions<Series> {
|
|
7
|
+
}
|
|
8
|
+
export declare const SeriesDateFunctions: (_s: any) => SeriesDateFunctions;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SeriesDateFunctions = void 0;
|
|
4
|
+
const functions_1 = require("../lazy/functions");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const SeriesDateFunctions = (_s) => {
|
|
7
|
+
const wrap = (method, ...args) => {
|
|
8
|
+
return (0, _1._Series)(_s[method](...args));
|
|
9
|
+
};
|
|
10
|
+
const wrapNullArgs = (method) => () => wrap(method);
|
|
11
|
+
return {
|
|
12
|
+
day: wrapNullArgs("day"),
|
|
13
|
+
hour: wrapNullArgs("hour"),
|
|
14
|
+
minute: wrapNullArgs("minute"),
|
|
15
|
+
month: wrapNullArgs("month"),
|
|
16
|
+
nanosecond: wrapNullArgs("nanosecond"),
|
|
17
|
+
ordinalDay: wrapNullArgs("ordinalDay"),
|
|
18
|
+
second: wrapNullArgs("second"),
|
|
19
|
+
strftime: (fmt) => wrap("strftime", fmt),
|
|
20
|
+
timestamp: wrapNullArgs("timestamp"),
|
|
21
|
+
week: wrapNullArgs("week"),
|
|
22
|
+
weekday: wrapNullArgs("weekday"),
|
|
23
|
+
year: wrapNullArgs("year"),
|
|
24
|
+
truncate: (every) => (0, _1._Series)(_s)
|
|
25
|
+
.toFrame()
|
|
26
|
+
.select((0, functions_1.col)(_s.name).dt.truncate(every))
|
|
27
|
+
.getColumn(_s.name),
|
|
28
|
+
round: (every) => (0, _1._Series)(_s)
|
|
29
|
+
.toFrame()
|
|
30
|
+
.select((0, functions_1.col)(_s.name).dt.round(every))
|
|
31
|
+
.getColumn(_s.name),
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
exports.SeriesDateFunctions = SeriesDateFunctions;
|