nodejs-polars
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -6,8 +6,6 @@ "use strict"; | ||
class DataType { | ||
constructor() { | ||
this.identity = "DataType"; | ||
} | ||
get variant() { | ||
return this.constructor.name.slice(1); | ||
} | ||
identity = "DataType"; | ||
get inner() { | ||
@@ -172,2 +170,4 @@ return null; | ||
class _Datetime extends DataType { | ||
timeUnit; | ||
timeZone; | ||
constructor(timeUnit, timeZone) { | ||
@@ -192,2 +192,3 @@ super(); | ||
class _List extends DataType { | ||
__inner; | ||
constructor(__inner) { | ||
@@ -210,2 +211,3 @@ super(); | ||
class _Struct extends DataType { | ||
fields; | ||
constructor(inner) { | ||
@@ -212,0 +214,0 @@ super(); |
@@ -5,2 +5,4 @@ "use strict"; | ||
class Field { | ||
name; | ||
dtype; | ||
constructor(name, dtype) { | ||
@@ -7,0 +9,0 @@ this.name = name; |
@@ -91,2 +91,4 @@ import * as series from "./series"; | ||
export import struct = lazy.struct; | ||
export import allHorizontal = lazy.allHorizontal; | ||
export import anyHorizontal = lazy.anyHorizontal; | ||
export import spearmanRankCorr = lazy.spearmanRankCorr; | ||
@@ -93,0 +95,0 @@ export import tail = lazy.tail; |
@@ -127,2 +127,4 @@ "use strict"; | ||
pl.struct = lazy.struct; | ||
pl.allHorizontal = lazy.allHorizontal; | ||
pl.anyHorizontal = lazy.anyHorizontal; | ||
pl.spearmanRankCorr = lazy.spearmanRankCorr; | ||
@@ -129,0 +131,0 @@ pl.tail = lazy.tail; |
@@ -375,3 +375,3 @@ /// <reference types="node" /> | ||
* | ||
* >>> pl.readJSONStream(readStream).then(df => console.log(df)); | ||
* >>> pl.readJSONStream(readStream, { format: "lines" }).then(df => console.log(df)); | ||
* shape: (4, 2) | ||
@@ -378,0 +378,0 @@ * ┌─────┬─────┐ |
"use strict"; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var _LineBatcher_lines, _LineBatcher_accumulatedLines, _LineBatcher_batchSize; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -45,13 +33,12 @@ exports.readJSONStream = exports.readCSVStream = exports.scanIPC = exports.readIPC = exports.scanParquet = exports.readAvro = exports.readParquet = exports.scanJson = exports.readJSON = exports.scanCSV = exports.readCSV = exports.readRecords = void 0; | ||
class LineBatcher extends stream_1.Stream.Transform { | ||
#lines; | ||
#accumulatedLines; | ||
#batchSize; | ||
constructor(options) { | ||
super(options); | ||
_LineBatcher_lines.set(this, void 0); | ||
_LineBatcher_accumulatedLines.set(this, void 0); | ||
_LineBatcher_batchSize.set(this, void 0); | ||
__classPrivateFieldSet(this, _LineBatcher_lines, [], "f"); | ||
__classPrivateFieldSet(this, _LineBatcher_accumulatedLines, 0, "f"); | ||
__classPrivateFieldSet(this, _LineBatcher_batchSize, options.batchSize, "f"); | ||
this.#lines = []; | ||
this.#accumulatedLines = 0; | ||
this.#batchSize = options.batchSize; | ||
} | ||
_transform(chunk, _encoding, done) { | ||
var _a; | ||
let begin = 0; | ||
@@ -62,8 +49,8 @@ let i = 0; | ||
// '\n' | ||
__classPrivateFieldSet(this, _LineBatcher_accumulatedLines, (_a = __classPrivateFieldGet(this, _LineBatcher_accumulatedLines, "f"), _a++, _a), "f"); | ||
if (__classPrivateFieldGet(this, _LineBatcher_accumulatedLines, "f") === __classPrivateFieldGet(this, _LineBatcher_batchSize, "f")) { | ||
__classPrivateFieldGet(this, _LineBatcher_lines, "f").push(chunk.subarray(begin, i + 1)); | ||
this.push(Buffer.concat(__classPrivateFieldGet(this, _LineBatcher_lines, "f"))); | ||
__classPrivateFieldSet(this, _LineBatcher_lines, [], "f"); | ||
__classPrivateFieldSet(this, _LineBatcher_accumulatedLines, 0, "f"); | ||
this.#accumulatedLines++; | ||
if (this.#accumulatedLines === this.#batchSize) { | ||
this.#lines.push(chunk.subarray(begin, i + 1)); | ||
this.push(Buffer.concat(this.#lines)); | ||
this.#lines = []; | ||
this.#accumulatedLines = 0; | ||
begin = i + 1; | ||
@@ -74,11 +61,10 @@ } | ||
} | ||
__classPrivateFieldGet(this, _LineBatcher_lines, "f").push(chunk.subarray(begin)); | ||
this.#lines.push(chunk.subarray(begin)); | ||
done(); | ||
} | ||
_flush(done) { | ||
this.push(Buffer.concat(__classPrivateFieldGet(this, _LineBatcher_lines, "f"))); | ||
this.push(Buffer.concat(this.#lines)); | ||
done(); | ||
} | ||
} | ||
_LineBatcher_lines = new WeakMap(), _LineBatcher_accumulatedLines = new WeakMap(), _LineBatcher_batchSize = new WeakMap(); | ||
// helper functions | ||
@@ -85,0 +71,0 @@ function readCSVBuffer(buff, options) { |
import { Expr } from "./expr"; | ||
import { DataType } from "../datatypes"; | ||
import { Series } from "../series"; | ||
@@ -98,3 +99,3 @@ import { DataFrame } from "../dataframe"; | ||
*/ | ||
export declare function col(col: string | string[] | Series): Expr; | ||
export declare function col(col: string | string[] | Series | DataType): Expr; | ||
export declare function cols(col: string | string[]): Expr; | ||
@@ -353,1 +354,33 @@ export declare function cols(col: string, ...cols2: string[]): Expr; | ||
export declare function element(): Expr; | ||
/** Compute the bitwise AND horizontally across columns. | ||
Parameters | ||
---------- | ||
*exprs | ||
Column(s) to use in the aggregation. Accepts expression input. Strings are | ||
parsed as column names, other non-expression inputs are parsed as literals. | ||
Examples | ||
-------- | ||
>>> const df = pl.DataFrame( | ||
... { | ||
... "a": [false, false, true, true], | ||
... "b": [false, true, null, true], | ||
... "c": ["w", "x", "y", "z"], | ||
... } | ||
... ) | ||
>>> df.withColumns(pl.allHorizontal(["a", "b"])) | ||
shape: (4, 4) | ||
┌───────┬───────┬─────┬───────┐ | ||
│ a ┆ b ┆ c ┆ all │ | ||
│ --- ┆ --- ┆ --- ┆ --- │ | ||
│ bool ┆ bool ┆ str ┆ bool │ | ||
╞═══════╪═══════╪═════╪═══════╡ | ||
│ false ┆ false ┆ w ┆ false │ | ||
│ false ┆ true ┆ x ┆ false │ | ||
│ true ┆ null ┆ y ┆ null │ | ||
│ true ┆ true ┆ z ┆ true │ | ||
└───────┴───────┴─────┴───────┘ | ||
*/ | ||
export declare function allHorizontal(exprs: ExprOrString | ExprOrString[]): Expr; | ||
export declare function anyHorizontal(exprs: ExprOrString | ExprOrString[]): Expr; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.element = exports.struct = exports.list = exports.tail = exports.spearmanRankCorr = exports.select = exports.quantile = exports.pearsonCorr = exports.nUnique = exports.median = exports.mean = exports.last = exports.head = exports.groups = exports.format = exports.first = exports.exclude = exports.cov = exports.count = exports.concatString = exports.concatList = exports.avg = exports.argSortBy = exports.all = exports.intRanges = exports.intRange = exports.lit = exports.cols = exports.col = void 0; | ||
exports.anyHorizontal = exports.allHorizontal = exports.element = exports.struct = exports.list = exports.tail = exports.spearmanRankCorr = exports.select = exports.quantile = exports.pearsonCorr = exports.nUnique = exports.median = exports.mean = exports.last = exports.head = exports.groups = exports.format = exports.first = exports.exclude = exports.cov = exports.count = exports.concatString = exports.concatList = exports.avg = exports.argSortBy = exports.all = exports.intRanges = exports.intRange = exports.lit = exports.cols = exports.col = void 0; | ||
const expr_1 = require("./expr"); | ||
@@ -113,2 +113,5 @@ const series_1 = require("../series"); | ||
} | ||
else if (typeof col === "object" && Object.values(col)[0] === "DataType") { | ||
return (0, expr_1._Expr)(polars_internal_1.default.dtypeCols([col])); | ||
} | ||
else { | ||
@@ -434,2 +437,75 @@ return (0, expr_1._Expr)(polars_internal_1.default.col(col)); | ||
exports.element = element; | ||
/** Compute the bitwise AND horizontally across columns. | ||
Parameters | ||
---------- | ||
*exprs | ||
Column(s) to use in the aggregation. Accepts expression input. Strings are | ||
parsed as column names, other non-expression inputs are parsed as literals. | ||
Examples | ||
-------- | ||
>>> const df = pl.DataFrame( | ||
... { | ||
... "a": [false, false, true, true], | ||
... "b": [false, true, null, true], | ||
... "c": ["w", "x", "y", "z"], | ||
... } | ||
... ) | ||
>>> df.withColumns(pl.allHorizontal(["a", "b"])) | ||
shape: (4, 4) | ||
┌───────┬───────┬─────┬───────┐ | ||
│ a ┆ b ┆ c ┆ all │ | ||
│ --- ┆ --- ┆ --- ┆ --- │ | ||
│ bool ┆ bool ┆ str ┆ bool │ | ||
╞═══════╪═══════╪═════╪═══════╡ | ||
│ false ┆ false ┆ w ┆ false │ | ||
│ false ┆ true ┆ x ┆ false │ | ||
│ true ┆ null ┆ y ┆ null │ | ||
│ true ┆ true ┆ z ┆ true │ | ||
└───────┴───────┴─────┴───────┘ | ||
*/ | ||
function allHorizontal(exprs) { | ||
exprs = Array.isArray(exprs) ? exprs : [exprs]; | ||
exprs = (0, utils_1.selectionToExprList)(exprs); | ||
return (0, expr_1._Expr)(polars_internal_1.default.allHorizontal(exprs)); | ||
} | ||
exports.allHorizontal = allHorizontal; | ||
/* | ||
Compute the bitwise OR horizontally across columns. | ||
Parameters | ||
---------- | ||
*exprs | ||
Column(s) to use in the aggregation. Accepts expression input. Strings are | ||
parsed as column names, other non-expression inputs are parsed as literals. | ||
Examples | ||
-------- | ||
>>> const df = pl.DataFrame( | ||
... { | ||
... "a": [false, false, true, null], | ||
... "b": [false, true, null, null], | ||
... "c": ["w", "x", "y", "z"], | ||
... } | ||
... ) | ||
>>> df.withColumns(pl.anyHorizontal([pl.col("a"), pl.col("b")])) | ||
shape: (4, 4) | ||
┌───────┬───────┬─────┬───────┐ | ||
│ a ┆ b ┆ c ┆ any │ | ||
│ --- ┆ --- ┆ --- ┆ --- │ | ||
│ bool ┆ bool ┆ str ┆ bool │ | ||
╞═══════╪═══════╪═════╪═══════╡ | ||
│ false ┆ false ┆ w ┆ false │ | ||
│ false ┆ true ┆ x ┆ true │ | ||
│ true ┆ null ┆ y ┆ true │ | ||
│ null ┆ null ┆ z ┆ null │ | ||
└───────┴───────┴─────┴───────┘ | ||
*/ | ||
function anyHorizontal(exprs) { | ||
exprs = Array.isArray(exprs) ? exprs : [exprs]; | ||
exprs = (0, utils_1.selectionToExprList)(exprs); | ||
return (0, expr_1._Expr)(polars_internal_1.default.anyHorizontal(exprs)); | ||
} | ||
exports.anyHorizontal = anyHorizontal; | ||
// // export function collect_all() {} | ||
@@ -436,0 +512,0 @@ // // export function all() {} // fold |
@@ -107,7 +107,7 @@ "use strict"; | ||
}, | ||
argSort(reverse = false, nullsLast = true, maintain_order = false) { | ||
argSort(reverse = false, nullsLast = true, multithreaded = true, maintainOrder = false) { | ||
if (typeof reverse === "boolean") { | ||
return _Series(_s.argsort(reverse, nullsLast, maintain_order, false)); | ||
return _Series(_s.argsort(reverse, nullsLast, multithreaded, maintainOrder)); | ||
} | ||
return _Series(_s.argsort(reverse.reverse, reverse.nullsLast ?? nullsLast, reverse.maintain_order ?? maintain_order)); | ||
return _Series(_s.argsort(reverse.reverse, reverse.nullsLast ?? nullsLast, reverse.multithreaded ?? multithreaded, reverse.maintainOrder ?? maintainOrder)); | ||
}, | ||
@@ -114,0 +114,0 @@ argTrue() { |
@@ -52,3 +52,9 @@ "use strict"; | ||
if ((0, types_1.isRegExp)(r)) { | ||
return r.source; | ||
if (r.flags.includes("g")) { | ||
throw new Error("global flag is not supported"); | ||
} | ||
if (r.flags.includes("y")) { | ||
throw new Error("sticky flag is not supported"); | ||
} | ||
return r.flags ? `(?${r.flags})${r.source}` : r.source; | ||
} | ||
@@ -55,0 +61,0 @@ return r; |
{ | ||
"name": "nodejs-polars", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"repository": "https://github.com/pola-rs/nodejs-polars.git", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"license": "MIT", | ||
"main": "bin/index.js", | ||
@@ -35,3 +35,3 @@ "files": [ | ||
"engines": { | ||
"node": ">= 16" | ||
"node": ">= 18" | ||
}, | ||
@@ -50,4 +50,4 @@ "publishConfig": { | ||
"format:rs": "cargo fmt", | ||
"lint:ts:fix": "rome check --apply-unsafe {polars,__tests__} && rome format --write {polars,__tests__}", | ||
"lint:ts": "rome check {polars,__tests__} && rome format {polars,__tests__}", | ||
"lint:ts:fix": "biome check --apply-unsafe {polars,__tests__} && biome format --write {polars,__tests__}", | ||
"lint:ts": "biome check {polars,__tests__} && biome format {polars,__tests__}", | ||
"lint": "yarn lint:ts && yarn format:rs", | ||
@@ -60,16 +60,16 @@ "prepublishOnly": "napi prepublish -t npm", | ||
"devDependencies": { | ||
"@napi-rs/cli": "^2.16.2", | ||
"@types/chance": "^1.1.3", | ||
"@types/jest": "^29.5.3", | ||
"@types/node": "^20.4.2", | ||
"@biomejs/biome": "^1.0.0", | ||
"@napi-rs/cli": "^2.16.3", | ||
"@types/chance": "^1.1.4", | ||
"@types/jest": "^29.5.4", | ||
"@types/node": "^20.5.9", | ||
"chance": "^1.1.11", | ||
"jest": "^29.6.1", | ||
"rome": "^12.1.3", | ||
"jest": "^29.6.4", | ||
"source-map-support": "^0.5.21", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.1", | ||
"typedoc": "^0.24.8", | ||
"typescript": "5.1.6" | ||
"typedoc": "^0.25.1", | ||
"typescript": "5.2.2" | ||
}, | ||
"packageManager": "yarn@3.6.1", | ||
"packageManager": "yarn@3.6.2", | ||
"workspaces": [ | ||
@@ -79,12 +79,12 @@ "benches" | ||
"optionalDependencies": { | ||
"nodejs-polars-win32-x64-msvc": "0.8.1", | ||
"nodejs-polars-darwin-x64": "0.8.1", | ||
"nodejs-polars-linux-x64-gnu": "0.8.1", | ||
"nodejs-polars-darwin-arm64": "0.8.1", | ||
"nodejs-polars-linux-arm64-gnu": "0.8.1", | ||
"nodejs-polars-linux-arm64-musl": "0.8.1", | ||
"nodejs-polars-android-arm64": "0.8.1", | ||
"nodejs-polars-win32-ia32-msvc": "0.8.1", | ||
"nodejs-polars-linux-x64-musl": "0.8.1" | ||
"nodejs-polars-win32-x64-msvc": "0.8.2", | ||
"nodejs-polars-darwin-x64": "0.8.2", | ||
"nodejs-polars-linux-x64-gnu": "0.8.2", | ||
"nodejs-polars-darwin-arm64": "0.8.2", | ||
"nodejs-polars-linux-arm64-gnu": "0.8.2", | ||
"nodejs-polars-linux-arm64-musl": "0.8.2", | ||
"nodejs-polars-android-arm64": "0.8.2", | ||
"nodejs-polars-win32-ia32-msvc": "0.8.2", | ||
"nodejs-polars-linux-x64-musl": "0.8.2" | ||
} | ||
} |
@@ -115,3 +115,3 @@ # Polars | ||
### Minimum Requirements | ||
- Node version `>=16` | ||
- Node version `>=18` | ||
- Rust version `>=1.59` - *Only needed for development* | ||
@@ -162,2 +162,5 @@ | ||
## Webpack configuration | ||
To use `nodejs-polars` with [Webpack](https://webpack.js.org) please use [node-loader](https://github.com/webpack-contrib/node-loader) and `webpack.config.js` | ||
## Acknowledgements | ||
@@ -164,0 +167,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
443141
0
12171
173