Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodejs-polars

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodejs-polars - npm Package Compare versions

Comparing version 0.0.8 to 0.1.0

bin/lazy/expr/datetime.d.ts

21

bin/dataframe.d.ts

@@ -9,4 +9,5 @@ /// <reference types="node" />

import { ColumnSelection, FillNullStrategy, ColumnsOrExpr, ValueOrArray, ExprOrString } from "./utils";
import { Arithmetic } from "./shared_traits";
declare const inspect: unique symbol;
export interface DataFrame {
export interface DataFrame extends Arithmetic<DataFrame> {
/** @ignore */

@@ -21,6 +22,6 @@ _df: JsDataFrame;

width: number;
columns: string[];
get columns(): string[];
set columns(cols: string[]);
[inspect](): string;
[Symbol.iterator](): Generator<any, void, any>;
inner(): JsDataFrame;
/**

@@ -619,6 +620,2 @@ * Very cheap deep clone.

/**
* Apply a function on Self.
*/
pipe<T>(func: (...args: any[]) => T, ...args: any[]): T;
/**
* Aggregate the columns of this DataFrame to their quantile value.

@@ -1212,12 +1209,2 @@ * @example

where(predicate: any): DataFrame;
add(other: any): DataFrame;
sub(other: any): DataFrame;
div(other: any): DataFrame;
mul(other: any): DataFrame;
rem(other: any): DataFrame;
plus(other: any): DataFrame;
minus(other: any): DataFrame;
divideBy(other: any): DataFrame;
multiplyBy(other: any): DataFrame;
modulo(other: any): DataFrame;
}

@@ -1224,0 +1211,0 @@ /**

@@ -18,2 +18,3 @@ "use strict";

const utils_1 = require("./utils");
const functions_2 = require("./lazy/functions");
const inspect = Symbol.for("nodejs.util.inspect.custom");

@@ -65,2 +66,3 @@ function prepareOtherArg(anyValue) {

const df = {
/** @ignore */
_df,

@@ -94,3 +96,5 @@ [inspect]() {

},
inner: () => _df,
set columns(names) {
unwrap("set_column_names", { names });
},
clone: noArgWrap("clone"),

@@ -118,4 +122,3 @@ describe() {

},
drop(name, ...names) {
names.unshift(name);
drop(...names) {
if (!Array.isArray(names[0]) && names.length === 1) {

@@ -147,3 +150,4 @@ return wrap("drop", { name: names[0] });

explode(...columns) {
return (0, exports.dfWrapper)(_df).lazy()
return (0, exports.dfWrapper)(_df)
.lazy()
.explode(columns)

@@ -193,3 +197,5 @@ .collectSync({ noOptimization: true });

insertAtIdx: (index, s) => unwrap("insert_at_idx", { index, new_col: s._series }),
interpolate: noArgWrap("interpolate"),
interpolate() {
return this.select((0, functions_2.col)("*").interpolate());
},
isDuplicated: () => (0, series_1.seriesWrapper)(unwrap("is_duplicated")),

@@ -406,12 +412,2 @@ isEmpty: () => unwrap("height") === 0,

toString: () => noArgUnwrap("as_str")().toString(),
add: (other) => wrap("add", { other: prepareOtherArg(other)._series }),
sub: (other) => wrap("sub", { other: prepareOtherArg(other)._series }),
div: (other) => wrap("div", { other: prepareOtherArg(other)._series }),
mul: (other) => wrap("mul", { other: prepareOtherArg(other)._series }),
rem: (other) => wrap("rem", { other: prepareOtherArg(other)._series }),
plus: (other) => wrap("add", { other: prepareOtherArg(other)._series }),
minus: (other) => wrap("sub", { other: prepareOtherArg(other)._series }),
divideBy: (other) => wrap("div", { other: prepareOtherArg(other)._series }),
multiplyBy: (other) => wrap("mul", { other: prepareOtherArg(other)._series }),
modulo: (other) => wrap("rem", { other: prepareOtherArg(other)._series }),
var: noArgWrap("var"),

@@ -452,3 +448,13 @@ map: (fn) => map((0, exports.dfWrapper)(_df), fn),

return this.filter(predicate);
}
},
add: (other) => wrap("add", { other: prepareOtherArg(other)._series }),
sub: (other) => wrap("sub", { other: prepareOtherArg(other)._series }),
div: (other) => wrap("div", { other: prepareOtherArg(other)._series }),
mul: (other) => wrap("mul", { other: prepareOtherArg(other)._series }),
rem: (other) => wrap("rem", { other: prepareOtherArg(other)._series }),
plus: (other) => wrap("add", { other: prepareOtherArg(other)._series }),
minus: (other) => wrap("sub", { other: prepareOtherArg(other)._series }),
divideBy: (other) => wrap("div", { other: prepareOtherArg(other)._series }),
multiplyBy: (other) => wrap("mul", { other: prepareOtherArg(other)._series }),
modulo: (other) => wrap("rem", { other: prepareOtherArg(other)._series }),
};

@@ -474,6 +480,2 @@ return new Proxy(df, {

}
if (typeof prop !== "symbol" && !Number.isNaN(Number(prop))) {
target.replaceAtIdx(Number(prop), receiver);
return true;
}
}

@@ -480,0 +482,0 @@ Reflect.set(target, prop, receiver);

@@ -104,3 +104,3 @@ import { DataFrame } from "./dataframe";

*/
head(n: number): DataFrame;
head(n?: number): DataFrame;
/**

@@ -149,3 +149,3 @@ * Aggregate the last values in the group.

sum(): DataFrame;
tail(): DataFrame;
tail(n?: number): DataFrame;
toString(): string;

@@ -156,3 +156,3 @@ }

};
export declare function GroupBy(df: DataFrame, by: string[], maintainOrder?: boolean, downsample?: boolean): GroupBy;
export declare function GroupBy(df: DataFrame, by: string[], maintainOrder?: boolean): GroupBy;
export {};

@@ -29,3 +29,2 @@ "use strict";

const util_1 = __importDefault(require("util"));
const error_1 = require("./error");
const functions_1 = require("./lazy/functions");

@@ -35,8 +34,5 @@ const polars_internal_1 = __importDefault(require("./internals/polars_internal"));

const inspectOpts = { colors: true, depth: null };
function GroupBy(df, by, maintainOrder = false, downsample = false) {
function GroupBy(df, by, maintainOrder = false) {
const customInspect = () => util_1.default.formatWithOptions(inspectOpts, "GroupBy {by: %O}", by);
const pivot = (opts, valuesCol) => {
if (downsample) {
throw new error_1.InvalidOperationError("pivot", "downsample");
}
if (typeof opts === "string") {

@@ -43,0 +39,0 @@ if (valuesCol) {

@@ -21,3 +21,3 @@ import { DataFrame } from "../dataframe";

/**
* Representation of a Lazy computation graph/ query.
* Representation of a Lazy computation graph / query.
*/

@@ -32,20 +32,21 @@ export interface LazyDataFrame {

cache(): LazyDataFrame;
clone(): LazyDataFrame;
/**
*
* Collect into a DataFrame.
* Note: use `fetch` if you want to run this query on the first `n` rows only.
* This can be a huge time saver in debugging queries.
* @param typeCoercion -Do type coercion optimization.
* @param predicatePushdown - Do predicate pushdown optimization.
* @param projectionPushdown - Do projection pushdown optimization.
* @param simplifyExpression - Run simplify expressions optimization.
* @param stringCache - Use a global string cache in this query.
* This is needed if you want to join on categorical columns.
* Caution!
* * If you already have set a global string cache, set this to `false` as this will reset the
* * global cache when the query is finished.
* @param noOptimization - Turn off optimizations.
* @return DataFrame
*
*/
*
* Collect into a DataFrame.
* Note: use `fetch` if you want to run this query on the first `n` rows only.
* This can be a huge time saver in debugging queries.
* @param typeCoercion -Do type coercion optimization.
* @param predicatePushdown - Do predicate pushdown optimization.
* @param projectionPushdown - Do projection pushdown optimization.
* @param simplifyExpression - Run simplify expressions optimization.
* @param stringCache - Use a global string cache in this query.
* This is needed if you want to join on categorical columns.
* Caution!
* * If you already have set a global string cache, set this to `false` as this will reset the
* * global cache when the query is finished.
* @param noOptimization - Turn off optimizations.
* @return DataFrame
*
*/
collect(opts?: LazyOptions): Promise<DataFrame>;

@@ -93,3 +94,2 @@ collectSync(opts?: LazyOptions): DataFrame;

*
*
* Note that the fetch does not guarantee the final number of rows in the DataFrame.

@@ -106,4 +106,7 @@ * Filter, join operations and a lower number of rows available in the scanned file influence

*/
fetch(numRows?: number): DataFrame;
fetch(numRows: number, opts: LazyOptions): DataFrame;
fetch(numRows?: number): Promise<DataFrame>;
fetch(numRows: number, opts: LazyOptions): Promise<DataFrame>;
/** Behaves the same as fetch, but will perform the actions syncronously */
fetchSync(numRows?: number): DataFrame;
fetchSync(numRows: number, opts: LazyOptions): DataFrame;
/**

@@ -110,0 +113,0 @@ * Fill missing values

@@ -32,2 +32,3 @@ "use strict";

cache: wrapNullArgs("cache"),
clone: wrapNullArgs("clone"),
collectSync: () => (0, dataframe_1.dfWrapper)(unwrap("collectSync")),

@@ -62,3 +63,3 @@ collect: () => unwrap("collect").then(dataframe_1.dfWrapper),

},
fetch(numRows, opts) {
fetchSync(numRows, opts) {
if (opts?.noOptimization) {

@@ -74,4 +75,15 @@ opts.predicatePushdown = false;

},
fetch(numRows, opts) {
if (opts?.noOptimization) {
opts.predicatePushdown = false;
opts.projectionPushdown = false;
}
if (opts) {
const _ldf = unwrap("optimizationToggle", opts);
return unwrap("fetch", { numRows }, _ldf).then(dataframe_1.dfWrapper);
}
return unwrap("fetch", { numRows }).then(dataframe_1.dfWrapper);
},
first() {
return this.fetch(1);
return this.fetchSync(1);
},

@@ -78,0 +90,0 @@ fillNull(exprOrValue) {

import { DataType } from "../datatypes";
import { ExprOrString, FillNullStrategy, RankMethod, RollingOptions } from "../utils";
import { ExprOrString, FillNullStrategy, RankMethod, INSPECT_SYMBOL } from "../utils";
import { Series } from "../series";
declare const inspect: unique symbol;
declare type JsExpr = any;
/**
* namespace containing expr list functions
*/
export interface ExprListFunctions {
/**
* Get the value by index in the sublists.
* So index `0` would return the first item of every sublist
* and index `-1` would return the last item of every sublist
* if an index is out of bounds, it will return a `null`.
*/
get(index: number): Expr;
/** Get the first value of the sublists. */
first(): Expr;
/** Get the last value of the sublists. */
last(): Expr;
lengths(): Expr;
max(): Expr;
mean(): Expr;
min(): Expr;
reverse(): Expr;
sort(reverse?: boolean): Expr;
sort(opt: {
reverse: boolean;
}): Expr;
sum(): Expr;
unique(): Expr;
}
/**
* namespace containing expr string functions
*/
export interface ExprStringFunctions {
/**
* Vertically concat the values in the Series to a single string value.
* @example
* ```
* >>> df = pl.DataFrame({"foo": [1, null, 2]})
* >>> df = df.select(pl.col("foo").str.concat("-"))
* >>> df
* shape: (1, 1)
* ┌──────────┐
* │ foo │
* │ --- │
* │ str │
* ╞══════════╡
* │ 1-null-2 │
* └──────────┘
* ```
*/
concat(delimiter: string): Expr;
/** Check if strings in Series contain regex pattern. */
contains(pat: string | RegExp): Expr;
/**
* Decodes a value using the provided encoding
* @param encoding - hex | base64
* @param strict - how to handle invalid inputs
*
* - true: method will throw error if unable to decode a value
* - false: unhandled values will be replaced with `null`
* @example
* ```
* >>> df = pl.DataFrame({"strings": ["666f6f", "626172", null]})
* >>> df.select(col("strings").str.decode("hex"))
* shape: (3, 1)
* ┌─────────┐
* │ strings │
* │ --- │
* │ str │
* ╞═════════╡
* │ foo │
* ├╌╌╌╌╌╌╌╌╌┤
* │ bar │
* ├╌╌╌╌╌╌╌╌╌┤
* │ null │
* └─────────┘
* ```
*/
decode(encoding: "hex" | "base64", strict?: boolean): Expr;
decode(options: {
encoding: "hex" | "base64";
strict?: boolean;
}): Expr;
/**
* Encodes a value using the provided encoding
* @param encoding - hex | base64
* @example
* ```
* >>> df = pl.DataFrame({"strings", ["foo", "bar", null]})
* >>> df.select(col("strings").str.encode("hex"))
* shape: (3, 1)
* ┌─────────┐
* │ strings │
* │ --- │
* │ str │
* ╞═════════╡
* │ 666f6f │
* ├╌╌╌╌╌╌╌╌╌┤
* │ 626172 │
* ├╌╌╌╌╌╌╌╌╌┤
* │ null │
* └─────────┘
* ```
*/
encode(encoding: "hex" | "base64"): Expr;
/**
* Extract the target capture group from provided patterns.
* @param pattern A valid regex pattern
* @param groupIndex Index of the targeted capture group.
* Group 0 mean the whole pattern, first group begin at index 1
* Default to the first capture group
* @returns Utf8 array. Contain null if original value is null or regex capture nothing.
* @example
* ```
* > df = pl.DataFrame({
* ... 'a': [
* ... 'http://vote.com/ballon_dor?candidate=messi&ref=polars',
* ... 'http://vote.com/ballon_dor?candidat=jorginho&ref=polars',
* ... 'http://vote.com/ballon_dor?candidate=ronaldo&ref=polars'
* ... ]})
* > df.select(pl.col('a').str.extract(/candidate=(\w+)/, 1))
* shape: (3, 1)
* ┌─────────┐
* │ a │
* │ --- │
* │ str │
* ╞═════════╡
* │ messi │
* ├╌╌╌╌╌╌╌╌╌┤
* │ null │
* ├╌╌╌╌╌╌╌╌╌┤
* │ ronaldo │
* └─────────┘
* ```
*/
extract(pat: string | RegExp, groupIndex: number): Expr;
/**
* Extract the first match of json string with provided JSONPath expression.
* Throw errors if encounter invalid json strings.
* All return value will be casted to Utf8 regardless of the original value.
* @see https://goessner.net/articles/JsonPath/
* @param jsonPath - A valid JSON path query string
* @returns Utf8 array. Contain null if original value is null or the `jsonPath` return nothing.
* @example
* ```
* >>> df = pl.DataFrame({
* ... 'json_val': [
* ... '{"a":"1"}',
* ... null,
* ... '{"a":2}',
* ... '{"a":2.1}',
* ... '{"a":true}'
* ... ]
* ... })
* >>> df.select(pl.col('json_val').str.jsonPathMatch('$.a')
* shape: (5,)
* Series: 'json_val' [str]
* [
* "1"
* null
* "2"
* "2.1"
* "true"
* ]
* ```
*/
jsonPathMatch(pat: string): Expr;
/** Get length of the string values in the Series. */
lengths(): Expr;
/** Remove leading whitespace. */
lstrip(): Expr;
/** Replace first regex match with a string value. */
replace(pat: string | RegExp, val: string): Expr;
/** Replace all regex matches with a string value. */
replaceAll(pat: string | RegExp, val: string): Expr;
/** Modify the strings to their lowercase equivalent. */
toLowerCase(): Expr;
/** Modify the strings to their uppercase equivalent. */
toUpperCase(): Expr;
/** Remove trailing whitespace. */
rstrip(): Expr;
/**
* Create subslices of the string values of a Utf8 Series.
* @param start - Start of the slice (negative indexing may be used).
* @param length - Optional length of the slice.
*/
slice(start: number, length?: number): Expr;
/**
* Parse a Series of dtype Utf8 to a Date/Datetime Series.
* @param datatype Date or Datetime.
* @param fmt formatting syntax. [Read more](https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html)
*/
strftime(datatype: DataType.Date, fmt?: string): Expr;
strftime(datatype: DataType.Datetime, fmt?: string): Expr;
}
export interface ExprDateTimeFunctions {
/**
* Extract day from underlying Date representation.
* Can be performed on Date and Datetime.
*
* Returns the day of month starting from 1.
* The return value ranges from 1 to 31. (The last day of month differs by months.)
* @returns day as pl.UInt32
*/
day(): Expr;
/**
* Extract hour from underlying DateTime representation.
* Can be performed on Datetime.
*
* Returns the hour number from 0 to 23.
* @returns Hour as UInt32
*/
hour(): Expr;
/**
* Extract minutes from underlying DateTime representation.
* Can be performed on Datetime.
*
* Returns the minute number from 0 to 59.
* @returns minute as UInt32
*/
minute(): Expr;
/**
* Extract month from underlying Date representation.
* Can be performed on Date and Datetime.
*
* Returns the month number starting from 1.
* The return value ranges from 1 to 12.
* @returns Month as UInt32
*/
month(): Expr;
/**
* Extract seconds from underlying DateTime representation.
* Can be performed on Datetime.
*
* Returns the number of nanoseconds since the whole non-leap second.
* The range from 1,000,000,000 to 1,999,999,999 represents the leap second.
* @returns Nanosecond as UInt32
*/
nanosecond(): Expr;
/**
* Extract ordinal day from underlying Date representation.
* Can be performed on Date and Datetime.
*
* Returns the day of year starting from 1.
* The return value ranges from 1 to 366. (The last day of year differs by years.)
* @returns Day as UInt32
*/
ordinalDay(): Expr;
/**
* Extract seconds from underlying DateTime representation.
* Can be performed on Datetime.
*
* Returns the second number from 0 to 59.
* @returns Second as UInt32
*/
second(): Expr;
/**
* Format Date/datetime with a formatting rule: See [chrono strftime/strptime](https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html).
*/
strftime(fmt: string): Expr;
/** Return timestamp in ms as Int64 type. */
timestamp(): Expr;
/**
* Extract the week from the underlying Date representation.
* Can be performed on Date and Datetime
*
* Returns the ISO week number starting from 1.
* The return value ranges from 1 to 53. (The last week of year differs by years.)
* @returns Week number as UInt32
*/
week(): Expr;
/**
* Extract the week day from the underlying Date representation.
* Can be performed on Date and Datetime.
*
* Returns the weekday number where monday = 0 and sunday = 6
* @returns Week day as UInt32
*/
weekday(): Expr;
/**
* Extract year from underlying Date representation.
* Can be performed on Date and Datetime.
*
* Returns the year number in the calendar date.
* @returns Year as Int32
*/
year(): Expr;
}
export interface Expr {
import * as expr from "./expr/";
import { Arithmetic, Comparison, Cumulative, Rolling } from "../shared_traits";
export interface Expr extends Rolling<Expr>, Arithmetic<Expr>, Comparison<Expr>, Cumulative<Expr> {
/** @ignore */
_expr: any;
get date(): ExprDateTimeFunctions;
get str(): ExprStringFunctions;
get lst(): ExprListFunctions;
[inspect](): string;
get date(): expr.Datetime;
get str(): expr.String;
get lst(): expr.List;
[INSPECT_SYMBOL](): string;
toString(): string;

@@ -371,39 +85,2 @@ /** Take absolute values */

count(): Expr;
/** Get an array with the cumulative count computed at every element. */
cumCount(reverse?: boolean): Expr;
cumCount({ reverse }: {
reverse: boolean;
}): Expr;
/** Get an array with the cumulative max computed at every element. */
cumMax(reverse?: boolean): Expr;
cumMax({ reverse }: {
reverse: boolean;
}): Expr;
/** Get an array with the cumulative min computed at every element. */
cumMin(reverse?: boolean): Expr;
cumMin({ reverse }: {
reverse: boolean;
}): Expr;
/**
* Get an array with the cumulative product computed at every element.
*
* @notes
* *Dtypes in {Int8, UInt8, Int16, UInt16} are cast to
* Int64 before summing to prevent overflow issues.*
*/
cumProd(reverse?: boolean): Expr;
cumProd({ reverse }: {
reverse: boolean;
}): Expr;
/**
* Get an array with the cumulative sum computed at every element.
*
* @notes
* *Dtypes in {Int8, UInt8, Int16, UInt16} are cast to
* Int64 before summing to prevent overflow issues.*
*/
cumSum(reverse?: boolean): Expr;
cumSum({ reverse }: {
reverse: boolean;
}): Expr;
/** Calculate the n-th discrete difference.

@@ -424,3 +101,2 @@ *

dot(other: any): Expr;
eq(other: any): Expr;
/**

@@ -510,4 +186,2 @@ * Exclude certain columns from a wildcard/regex selection.

forwardFill(): Expr;
gt(other: any): Expr;
gtEq(other: any): Expr;
/** Hash the Series. */

@@ -639,4 +313,2 @@ hash(k0?: number, k1?: number, k2?: number, k3?: number): Expr;

lowerBound(): Expr;
lt(other: any): Expr;
ltEq(other: any): Expr;
/** Compute the max value of the arrays in the list */

@@ -652,3 +324,2 @@ max(): Expr;

mode(): Expr;
neq(other: any): Expr;
/** Negate a boolean expression. */

@@ -778,116 +449,2 @@ not(): Expr;

/**
* __Apply a rolling max (moving max) over the values in this Series.__
*
* A window of length `window_size` will traverse the series. The values that fill this window
* will (optionally) be multiplied with the weights given by the `weight` vector.
*
* The resulting parameters' values will be aggregated into their sum.
* ___
* @param windowSize - The length of the window.
* @param weights - An optional slice with the same length as the window that will be multiplied
* elementwise with the values in the window.
* @param minPeriods The number of values in the window that should be non-null before computing a result.
* If undefined, it will be set equal to window size.
* @param center - Set the labels at the center of the window
* @see {@link rollingMean}, {@link rollingMin}, {@link rollingSum}, {@link rollingVar}
*/
rollingMax(options: RollingOptions): Expr;
rollingMax(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): Expr;
/**
* __Apply a rolling mean (moving mean) over the values in this Series.__
*
* A window of length `window_size` will traverse the series. The values that fill this window
* will (optionally) be multiplied with the weights given by the `weight` vector.
*
* The resulting parameters' values will be aggregated into their sum.
* ___
* @param windowSize - The length of the window.
* @param weights - An optional slice with the same length as the window that will be multiplied
* elementwise with the values in the window.
* @param minPeriods The number of values in the window that should be non-null before computing a result.
* If undefined, it will be set equal to window size.
* @param center - Set the labels at the center of the window
* @see {@link rollingMax}, {@link rollingMin}, {@link rollingSum}, {@link rollingVar}
*/
rollingMean(options: RollingOptions): Expr;
rollingMean(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): Expr;
/**
* __Apply a rolling min (moving min) over the values in this Series.__
*
* A window of length `window_size` will traverse the series. The values that fill this window
* will (optionally) be multiplied with the weights given by the `weight` vector.
*
* The resulting parameters' values will be aggregated into their sum.
* ___
* @param windowSize - The length of the window.
* @param weights - An optional slice with the same length as the window that will be multiplied
* elementwise with the values in the window.
* @param minPeriods The number of values in the window that should be non-null before computing a result.
* If undefined, it will be set equal to window size.
* @param center - Set the labels at the center of the window
* @see {@link rollingMax}, {@link rollingMean}, {@link rollingSum}, {@link rollingVar}
*/
rollingMin(options: RollingOptions): Expr;
rollingMin(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): Expr;
/**
* __Apply a rolling sum (moving sum) over the values in this Series.__
*
* A window of length `window_size` will traverse the series. The values that fill this window
* will (optionally) be multiplied with the weights given by the `weight` vector.
*
* The resulting parameters' values will be aggregated into their sum.
* ___
* @param windowSize - The length of the window.
* @param weights - An optional slice with the same length as the window that will be multiplied
* elementwise with the values in the window.
* @param minPeriods The number of values in the window that should be non-null before computing a result.
* If undefined, it will be set equal to window size.
* @param center - Set the labels at the center of the window
*/
rollingSum(options: RollingOptions): Expr;
rollingSum(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): Expr;
/**
* __Compute a rolling variance.__
*
* A window of length `window_size` will traverse the series. The values that fill this window
* will (optionally) be multiplied with the weights given by the `weight` vector.
*
* The resulting parameters' values will be aggregated into their sum.
* ___
* @param windowSize - The length of the window.
* @param weights - An optional slice with the same length as the window that will be multiplied
* elementwise with the values in the window.
* @param minPeriods The number of values in the window that should be non-null before computing a result.
* If undefined, it will be set equal to window size.
* @param center - Set the labels at the center of the window
* @see {@link rollingMax}, {@link rollingMin}, {@link rollingMean}, {@link rollingSum}
*/
rollingVar(options: RollingOptions): Expr;
rollingVar(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): Expr;
/** Compute a rolling median */
rollingMedian(windowSize: number): Expr;
rollingMedian({ windowSize }: {
windowSize: number;
}): Expr;
/**
* Compute a rolling quantile
* @param windowSize Size of the rolling window
* @param quantile quantile to compute
*/
rollingQuantile(windowSize: number, quantile: number): Expr;
rollingQuantile({ windowSize, quantile }: {
windowSize: number;
quantile: number;
}): Expr;
/**
* Compute a rolling skew
* @param windowSize Size of the rolling window
* @param bias If false, then the calculations are corrected for statistical bias.
*/
rollingSkew(windowSize: number, bias?: boolean): Expr;
rollingSkew({ windowSize, bias }: {
windowSize: number;
bias?: boolean;
}): Expr;
/**
* Round underlying floating point data by `decimals` digits.

@@ -982,3 +539,3 @@ * @param decimals Number of decimals to round by.

}
export declare const Expr: ((_expr: JsExpr) => Expr) & {
export declare const Expr: ((_expr: any) => Expr) & {
isExpr: (anyVal: any) => anyVal is Expr;

@@ -988,2 +545,1 @@ };

export declare const exprToLitOrExpr: (expr: any, stringToLit?: boolean) => Expr;
export {};
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -7,3 +26,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.exprToLitOrExpr = exports.Expr = void 0;
const datatypes_1 = require("../datatypes");
const polars_internal_1 = __importDefault(require("../internals/polars_internal"));

@@ -14,145 +32,3 @@ const functions_1 = require("./functions");

const series_1 = require("../series");
const inspect = Symbol.for("nodejs.util.inspect.custom");
const ExprListFunctions = (_expr) => {
const wrap = (method, args) => {
return (0, exports.Expr)(polars_internal_1.default.expr.lst[method]({ _expr, ...args }));
};
return {
get(index) {
return wrap("get", { index });
},
first() {
return wrap("get", { index: 0 });
},
last() {
return wrap("get", { index: -1 });
},
lengths() {
return wrap("lengths");
},
max() {
return wrap("max");
},
mean() {
return wrap("mean");
},
min() {
return wrap("min");
},
reverse() {
return wrap("reverse");
},
sort(reverse = false) {
return typeof reverse === "boolean" ?
wrap("sort", { reverse }) :
wrap("sort", reverse);
},
sum() {
return wrap("sum");
},
unique() {
return wrap("unique");
},
};
};
const ExprDateTimeFunctions = (_expr) => {
const wrap = (method, args) => {
return (0, exports.Expr)(polars_internal_1.default.expr.date[method]({ _expr, ...args }));
};
const wrapNullArgs = (method) => () => wrap(method);
return {
day: wrapNullArgs("day"),
hour: wrapNullArgs("hour"),
minute: wrapNullArgs("minute"),
month: wrapNullArgs("month"),
nanosecond: wrapNullArgs("nanosecond"),
ordinalDay: wrapNullArgs("ordinalDay"),
second: wrapNullArgs("second"),
strftime: (fmt) => wrap("strftime", { fmt }),
timestamp: wrapNullArgs("timestamp"),
week: wrapNullArgs("week"),
weekday: wrapNullArgs("weekday"),
year: wrapNullArgs("year"),
};
};
const ExprStringFunctions = (_expr) => {
const wrap = (method, args) => {
return (0, exports.Expr)(polars_internal_1.default.expr.str[method]({ _expr, ...args }));
};
const handleDecode = (encoding, strict) => {
switch (encoding) {
case "hex":
return wrap(`decodeHex`, { strict });
case "base64":
return wrap(`decodeBase64`, { strict });
default:
throw new RangeError("supported encodings are 'hex' and 'base64'");
}
};
return {
concat(delimiter) {
return wrap("concat", { delimiter });
},
contains(pat) {
return wrap("contains", { pat: (0, utils_1.regexToString)(pat) });
},
decode(arg, strict = false) {
if (typeof arg === "string") {
return handleDecode(arg, strict);
}
return handleDecode(arg.encoding, arg.strict);
},
encode(encoding) {
switch (encoding) {
case "hex":
return wrap(`encodeHex`);
case "base64":
return wrap(`encodeBase64`);
default:
throw new RangeError("supported encodings are 'hex' and 'base64'");
}
},
extract(pat, groupIndex) {
return wrap("extract", { pat: (0, utils_1.regexToString)(pat), groupIndex });
},
jsonPathMatch(pat) {
return wrap("jsonPathMatch", { pat });
},
lengths() {
return wrap("lengths");
},
lstrip() {
return wrap("replace", { pat: /^\s*/.source, val: "" });
},
replace(pat, val) {
return wrap("replace", { pat: (0, utils_1.regexToString)(pat), val });
},
replaceAll(pat, val) {
return wrap("replaceAll", { pat: (0, utils_1.regexToString)(pat), val });
},
rstrip() {
return wrap("replace", { pat: /[ \t]+$/.source, val: "" });
},
slice(start, length) {
return wrap("slice", { start, length });
},
strftime(dtype, fmt) {
if (dtype === datatypes_1.DataType.Date) {
return wrap("parseDate", { fmt });
}
else if (dtype === datatypes_1.DataType.Datetime) {
return wrap("parseDateTime", { fmt });
}
else {
throw new Error(`only "DataType.Date" and "DataType.Datetime" are supported`);
}
},
toLowerCase() {
return wrap("toLowerCase");
},
toUpperCase() {
return wrap("toUpperCase");
},
};
};
const expr = __importStar(require("./expr/"));
const _Expr = (_expr) => {

@@ -187,5 +63,18 @@ const wrap = (method, args) => {

};
const rolling = (method) => (opts, weights, minPeriods, center) => {
const windowSize = opts?.["windowSize"] ?? (typeof opts === "number" ? opts : null);
if (windowSize === null) {
throw new Error("window size is required");
}
const callOpts = {
window_size: opts?.["windowSize"] ?? (typeof opts === "number" ? opts : null),
weights: opts?.["weights"] ?? weights,
min_periods: opts?.["minPeriods"] ?? minPeriods ?? windowSize,
center: opts?.["center"] ?? center ?? false,
};
return wrap(method, callOpts);
};
return {
_expr,
[inspect]() {
[utils_1.INSPECT_SYMBOL]() {
return polars_internal_1.default.expr.as_str({ _expr });

@@ -197,9 +86,9 @@ },

get str() {
return ExprStringFunctions(_expr);
return expr.StringFunctions(_expr);
},
get lst() {
return ExprListFunctions(_expr);
return expr.ListFunctions(_expr);
},
get date() {
return ExprDateTimeFunctions(_expr);
return expr.DateTimeFunctions(_expr);
},

@@ -227,3 +116,2 @@ abs: wrapNullArgs("abs"),

dot: wrapExprArg("dot"),
eq: wrapExprArg("eq"),
exclude(...columns) {

@@ -247,3 +135,2 @@ return wrap("exclude", { columns: columns.flat(2) });

},
fillNullWithStrategy: wrapUnary("fillNullWithStrategy", "strategy"),
filter: wrapExprArg("filter"),

@@ -254,4 +141,2 @@ first: wrapNullArgs("first"),

forwardFill: wrapNullArgs("forwardFill"),
gt: wrapExprArg("gt"),
gtEq: wrapExprArg("gtEq"),
hash(obj = 0, k1 = 1, k2 = 2, k3 = 3) {

@@ -293,4 +178,2 @@ if (typeof obj === "number" || typeof obj === "bigint") {

lowerBound: wrapNullArgs("lowerBound"),
lt: wrapExprArg("lt"),
ltEq: wrapExprArg("ltEq"),
max: wrapNullArgs("max"),

@@ -301,3 +184,2 @@ mean: wrapNullArgs("mean"),

mode: wrapNullArgs("mode"),
neq: wrapExprArg("neq"),
not: wrapNullArgs("not"),

@@ -316,5 +198,10 @@ nUnique: wrapNullArgs("nUnique"),

repeatBy: wrapExprArg("repeatBy"),
reshape: wrapUnary("reshape", "dims"),
reverse: wrapNullArgs("reverse"),
rollingMedian: wrapUnary("rollingMedian", "windowSize"),
rollingMax: rolling("rollingMax"),
rollingMean: rolling("rollingMean"),
rollingMin: rolling("rollingMin"),
rollingSum: rolling("rollingSum"),
rollingStd: rolling("rollingStd"),
rollingVar: rolling("rollingVar"),
rollingMedian: rolling("rollingMedian"),
rollingQuantile: wrapBinary("rollingQuantile", "windowSize", "quantile"),

@@ -362,3 +249,25 @@ rollingSkew(val, bias = true) {

where: wrapExprArg("filter"),
var: wrapNullArgs("var")
var: wrapNullArgs("var"),
add: wrapExprArg("add"),
sub: wrapExprArg("sub"),
div: wrapExprArg("div"),
mul: wrapExprArg("mul"),
rem: wrapExprArg("rem"),
plus: wrapExprArg("add"),
minus: wrapExprArg("sub"),
divideBy: wrapExprArg("div"),
multiplyBy: wrapExprArg("mul"),
modulo: wrapExprArg("rem"),
eq: wrapExprArg("eq"),
equals: wrapExprArg("eq"),
gtEq: wrapExprArg("gtEq"),
greaterThanEquals: wrapExprArg("gtEq"),
gt: wrapExprArg("gt"),
greaterThan: wrapExprArg("gt"),
ltEq: wrapExprArg("ltEq"),
lessThanEquals: wrapExprArg("ltEq"),
lt: wrapExprArg("lt"),
lessThan: wrapExprArg("lt"),
neq: wrapExprArg("neq"),
notEquals: wrapExprArg("neq"),
};

@@ -365,0 +274,0 @@ };

@@ -164,3 +164,3 @@ import { Expr } from "./expr";

*/
export declare function exclude(columns: string[] | string): any;
export declare function exclude(columns: string[] | string): Expr;
export declare function exclude(col: string, ...cols: string[]): Expr;

@@ -167,0 +167,0 @@ /** Get the first value. */

{
"name": "nodejs-polars",
"version": "0.0.8",
"version": "0.1.0",
"repository": "https://github.com/pola-rs/polars.git",

@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE",

@@ -6,3 +6,4 @@ import { DataType, DtypeToPrimitive, Optional } from "./datatypes";

import { DateTimeFunctions } from "./series/datetime";
import { RankMethod, RollingOptions } from "./utils";
import { RankMethod } from "./utils";
import { Arithmetic, Comparison, Cumulative, Rolling } from "./shared_traits";
declare const inspect: unique symbol;

@@ -15,3 +16,3 @@ declare type ValueOrNever<V> = V extends ArrayLike<infer U> ? Series<U> : never;

export declare type JsSeries = any;
export interface Series<T> extends ArrayLike<T> {
export interface Series<T> extends ArrayLike<T>, Rolling<Series<T>>, Arithmetic<Series<T>>, Comparison<Series<boolean>>, Cumulative<Series<T>> {
[n: number]: T;

@@ -29,24 +30,2 @@ /** @ignore */

inner(): JsSeries;
eq(field: Series<T> | number | bigint | string): Series<boolean>;
equals(field: Series<T> | number | bigint | string): Series<boolean>;
gtEq(field: Series<T> | number | bigint | string): Series<boolean>;
greaterThanEquals(field: Series<T> | number | bigint | string): Series<boolean>;
gt(field: Series<T> | number | bigint | string): Series<boolean>;
greaterThan(field: Series<T> | number | bigint | string): Series<boolean>;
ltEq(field: Series<T> | number | bigint | string): Series<boolean>;
lessThanEquals(field: Series<T> | number | bigint | string): Series<boolean>;
lt(field: Series<T> | number | bigint | string): Series<boolean>;
lessThan(field: Series<T> | number | bigint | string): Series<boolean>;
neq(field: Series<T> | number | bigint | string): Series<boolean>;
notEquals(field: Series<T> | number | bigint | string): Series<boolean>;
add(field: Series<T> | number | bigint): Series<T>;
sub(field: Series<T> | number | bigint): Series<T>;
div(field: Series<T> | number | bigint): Series<T>;
mul(field: Series<T> | number | bigint): Series<T>;
rem(field: Series<T> | number | bigint | string): Series<T>;
plus(field: Series<T> | number | bigint): Series<T>;
minus(field: Series<T> | number | bigint): Series<T>;
divideBy(field: Series<T> | number | bigint): Series<T>;
times(field: Series<T> | number | bigint): Series<T>;
modulo(field: Series<T> | number | bigint | string): Series<T>;
bitand(other: Series<any>): Series<T>;

@@ -141,135 +120,47 @@ bitor(other: Series<any>): Series<T>;

/**
* __Get an array with the cumulative max computes at every element.__
* __Quick summary statistics of a series. __
*
* Series with mixed datatypes will return summary statistics for the datatype of the first value.
* ___
* @param reverse - reverse the operation
* @example
* ```
* > const s = pl.Series("a", [1, 2, 3])
* > s.cumMax()
* shape: (3,)
* Series: 'b' [i64]
* [
* 1
* 2
* 3
* ]
* > const seriesNum = pl.Series([1,2,3,4,5])
* > series_num.describe()
*
* shape: (6, 2)
* ┌──────────────┬────────────────────┐
* │ statistic ┆ value │
* │ --- ┆ --- │
* │ str ┆ f64 │
* ╞══════════════╪════════════════════╡
* │ "min" ┆ 1 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
* │ "max" ┆ 5 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
* │ "null_count" ┆ 0.0 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
* │ "mean" ┆ 3 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
* │ "std" ┆ 1.5811388300841898 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
* │ "count" ┆ 5 │
* └──────────────┴────────────────────┘
*
* > series_str = pl.Series(["a", "a", None, "b", "c"])
* > series_str.describe()
*
* shape: (3, 2)
* ┌──────────────┬───────┐
* │ statistic ┆ value │
* │ --- ┆ --- │
* │ str ┆ i64 │
* ╞══════════════╪═══════╡
* │ "unique" ┆ 4 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
* │ "null_count" ┆ 1 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
* │ "count" ┆ 5 │
* └──────────────┴───────┘
* ```
*/
cumMax(): Series<T>;
cumMax(reverse: boolean): Series<T>;
cumMax({ reverse }: {
reverse: boolean;
}): Series<T>;
/**
* __Get an array with the cumulative min computed at every element.__
* ___
* @param reverse - reverse the operation
* @example
* ```
* > const s = pl.Series("a", [1, 2, 3])
* > s.cumMin()
* shape: (3,)
* Series: 'b' [i64]
* [
* 1
* 1
* 1
* ]
* ```
*/
cumMin(): Series<T>;
cumMin(reverse: boolean): Series<T>;
cumMin({ reverse }: {
reverse: boolean;
}): Series<T>;
/**
* __Get an array with the cumulative product computed at every element.__
* ___
* @param reverse - reverse the operation
* @example
* ```
* > const s = pl.Series("a", [1, 2, 3])
* > s.cumProd()
* shape: (3,)
* Series: 'b' [i64]
* [
* 1
* 2
* 6
* ]
* ```
*/
cumProd(): Series<T>;
cumProd(reverse: boolean): Series<T>;
cumProd({ reverse }: {
reverse: boolean;
}): Series<T>;
/**
* __Get an array with the cumulative sum computed at every element.__
* ___
* @param reverse - reverse the operation
* @example
* ```
* > const s = pl.Series("a", [1, 2, 3])
* > s.cumSum()
* shape: (3,)
* Series: 'b' [i64]
* [
* 1
* 3
* 6
* ]
* ```
*/
cumSum(): Series<T>;
cumSum(reverse: boolean): Series<T>;
cumSum({ reverse }: {
reverse: boolean;
}): Series<T>;
/**
* __Quick summary statistics of a series. __
*
* Series with mixed datatypes will return summary statistics for the datatype of the first value.
* ___
* @example
* ```
* > const seriesNum = pl.Series([1,2,3,4,5])
* > series_num.describe()
*
* shape: (6, 2)
* ┌──────────────┬────────────────────┐
* │ statistic ┆ value │
* │ --- ┆ --- │
* │ str ┆ f64 │
* ╞══════════════╪════════════════════╡
* │ "min" ┆ 1 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
* │ "max" ┆ 5 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
* │ "null_count" ┆ 0.0 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
* │ "mean" ┆ 3 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
* │ "std" ┆ 1.5811388300841898 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
* │ "count" ┆ 5 │
* └──────────────┴────────────────────┘
*
* > series_str = pl.Series(["a", "a", None, "b", "c"])
* > series_str.describe()
*
* shape: (3, 2)
* ┌──────────────┬───────┐
* │ statistic ┆ value │
* │ --- ┆ --- │
* │ str ┆ i64 │
* ╞══════════════╪═══════╡
* │ "unique" ┆ 4 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
* │ "null_count" ┆ 1 │
* ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
* │ "count" ┆ 5 │
* └──────────────┴───────┘
* ```
*/
describe(): DataFrame;

@@ -833,152 +724,2 @@ /**

/**
* __Apply a rolling max (moving max) over the values in this Series.__
*
* A window of length `window_size` will traverse the series. The values that fill this window
* will (optionally) be multiplied with the weights given by the `weight` vector.
*
* The resulting parameters' values will be aggregated into their sum.
* ___
* @param windowSize - The length of the window.
* @param weights - An optional slice with the same length as the window that will be multiplied
* elementwise with the values in the window.
* @param minPeriods The number of values in the window that should be non-null before computing a result.
* If undefined, it will be set equal to window size.
* @param center - Set the labels at the center of the window
* ___
* @example
* ```
* s = pl.Series("a", [100, 200, 300, 400, 500])
* s.rollingMax(2)
* shape: (5,)
* Series: '' [i64]
* [
* null
* null
* 300
* 400
* 500
* ]
* ```
* @see {@link rollingMean}, {@link rollingMin}, {@link rollingSum}, {@link rollingVar}
*/
rollingMax(options: RollingOptions): Series<T>;
rollingMax(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): Series<T>;
/**
* __Apply a rolling mean (moving mean) over the values in this Series.__
*
* A window of length `window_size` will traverse the series. The values that fill this window
* will (optionally) be multiplied with the weights given by the `weight` vector.
*
* The resulting parameters' values will be aggregated into their sum.
* ___
* @param windowSize - The length of the window.
* @param weights - An optional slice with the same length as the window that will be multiplied
* elementwise with the values in the window.
* @param minPeriods The number of values in the window that should be non-null before computing a result.
* If undefined, it will be set equal to window size.
* @param center - Set the labels at the center of the window
* ___
* @example
* ```
* s = pl.Series("a", [100, 200, 300, 400, 500])
* s.rollingMean(2)
* shape: (5,)
* Series: '' [i64]
* [
* null
* 150
* 250
* 350
* 450
* ]
* ```
* @see {@link rollingMax}, {@link rollingMin}, {@link rollingSum}, {@link rollingVar}
*/
rollingMean(options: RollingOptions): Series<T>;
rollingMean(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): Series<T>;
/**
* __Apply a rolling min (moving min) over the values in this Series.__
*
* A window of length `window_size` will traverse the series. The values that fill this window
* will (optionally) be multiplied with the weights given by the `weight` vector.
*
* The resulting parameters' values will be aggregated into their sum.
* ___
* @param windowSize - The length of the window.
* @param weights - An optional slice with the same length as the window that will be multiplied
* elementwise with the values in the window.
* @param minPeriods The number of values in the window that should be non-null before computing a result.
* If undefined, it will be set equal to window size.
* @param center - Set the labels at the center of the window
* ___
* @example
* ```
* s = pl.Series("a", [100, 200, 300, 400, 500])
* s.rollingMin(2)
* shape: (5,)
* Series: '' [i64]
* [
* null
* null
* 100
* 200
* 300
* ]
* ```
* @see {@link rollingMax}, {@link rollingMean}, {@link rollingSum}, {@link rollingVar}
*/
rollingMin(options: RollingOptions): Series<T>;
rollingMin(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): Series<T>;
/**
* __Apply a rolling sum (moving sum) over the values in this Series.__
*
* A window of length `window_size` will traverse the series. The values that fill this window
* will (optionally) be multiplied with the weights given by the `weight` vector.
*
* The resulting parameters' values will be aggregated into their sum.
* ___
* @param windowSize - The length of the window.
* @param weights - An optional slice with the same length as the window that will be multiplied
* elementwise with the values in the window.
* @param minPeriods The number of values in the window that should be non-null before computing a result.
* If undefined, it will be set equal to window size.
* @param center - Set the labels at the center of the window
* ___
* @example
* ```
* s = pl.Series("a", [1, 2, 3, 4, 5])
* s.rollingSum(2)
* shape: (5,)
* Series: '' [i64]
* [
* null
* 3
* 5
* 7
* 9
* ]
* ```
* @see {@link rollingMax}, {@link rollingMin}, {@link rollingMean}, {@link rollingVar}
*/
rollingSum(options: RollingOptions): Series<T>;
rollingSum(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): Series<T>;
/**
* __Compute a rolling variance.__
*
* A window of length `window_size` will traverse the series. The values that fill this window
* will (optionally) be multiplied with the weights given by the `weight` vector.
*
* The resulting parameters' values will be aggregated into their sum.
* ___
* @param windowSize - The length of the window.
* @param weights - An optional slice with the same length as the window that will be multiplied
* elementwise with the values in the window.
* @param minPeriods The number of values in the window that should be non-null before computing a result.
* If undefined, it will be set equal to window size.
* @param center - Set the labels at the center of the window
* @see {@link rollingMax}, {@link rollingMin}, {@link rollingMean}, {@link rollingSum}
*/
rollingVar(options: RollingOptions): Series<T>;
rollingVar(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): Series<T>;
/**
* Round underlying floating point data by `decimals` digits.

@@ -985,0 +726,0 @@ *

@@ -148,2 +148,8 @@ "use strict";

},
cumCount(reverse) {
return this
.toFrame()
.select((0, functions_1.col)(this.name).cumCount(reverse))
.getColumn(this.name);
},
cumMax(reverse = false) {

@@ -401,3 +407,17 @@ return typeof reverse === "boolean" ?

rollingSum: rolling("rolling_sum"),
rollingStd: rolling("rolling_std"),
rollingVar: rolling("rolling_var"),
rollingMedian: rolling("rollingMedian"),
rollingQuantile(windowSize, quantile) {
return this
.toFrame()
.select((0, functions_1.col)(this.name).rollingQuantile(windowSize, quantile))
.getColumn(this.name);
},
rollingSkew(windowSize, bias) {
return this
.toFrame()
.select((0, functions_1.col)(this.name).rollingSkew(windowSize, bias))
.getColumn(this.name);
},
round(opt) {

@@ -490,3 +510,3 @@ if (this.isNumeric()) {

takeEvery: (n) => wrap("take_every", { n }),
times: (field) => dtypeAccessor(wrap)("mul", { field, key: "other" }),
multiplyBy: (field) => dtypeAccessor(wrap)("mul", { field, key: "other" }),
toArray() {

@@ -493,0 +513,0 @@ const series = (0, exports.seriesWrapper)(_s);

@@ -27,1 +27,2 @@ import { Expr } from "./lazy/expr";

export declare const regexToString: (r: string | RegExp) => string;
export declare const INSPECT_SYMBOL: unique symbol;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.regexToString = exports.isExprArray = exports.isSeriesArray = exports.isDataFrameArray = exports.range = exports.isPath = exports.selectionToExprList = exports.columnOrColumnsStrict = exports.columnOrColumns = void 0;
exports.INSPECT_SYMBOL = exports.regexToString = exports.isExprArray = exports.isSeriesArray = exports.isDataFrameArray = exports.range = exports.isPath = exports.selectionToExprList = exports.columnOrColumnsStrict = exports.columnOrColumns = void 0;
const expr_1 = require("./lazy/expr");

@@ -48,1 +48,2 @@ const path_1 = __importDefault(require("path"));

exports.regexToString = regexToString;
exports.INSPECT_SYMBOL = Symbol.for("nodejs.util.inspect.custom");
{
"name": "nodejs-polars",
"version": "0.0.8",
"version": "0.1.0",
"repository": "https://github.com/pola-rs/polars.git",

@@ -89,14 +89,14 @@ "license": "SEE LICENSE IN LICENSE",

"optionalDependencies": {
"nodejs-polars-win32-x64-msvc": "0.0.8",
"nodejs-polars-darwin-x64": "0.0.8",
"nodejs-polars-linux-x64-gnu": "0.0.8",
"nodejs-polars-win32-ia32-msvc": "0.0.8",
"nodejs-polars-linux-arm64-gnu": "0.0.8",
"nodejs-polars-linux-arm-gnueabihf": "0.0.8",
"nodejs-polars-darwin-arm64": "0.0.8",
"nodejs-polars-android-arm64": "0.0.8",
"nodejs-polars-linux-x64-musl": "0.0.8",
"nodejs-polars-linux-arm64-musl": "0.0.8",
"nodejs-polars-win32-arm64-msvc": "0.0.8"
"nodejs-polars-win32-x64-msvc": "0.1.0",
"nodejs-polars-darwin-x64": "0.1.0",
"nodejs-polars-linux-x64-gnu": "0.1.0",
"nodejs-polars-win32-ia32-msvc": "0.1.0",
"nodejs-polars-linux-arm64-gnu": "0.1.0",
"nodejs-polars-linux-arm-gnueabihf": "0.1.0",
"nodejs-polars-darwin-arm64": "0.1.0",
"nodejs-polars-android-arm64": "0.1.0",
"nodejs-polars-linux-x64-musl": "0.1.0",
"nodejs-polars-linux-arm64-musl": "0.1.0",
"nodejs-polars-win32-arm64-msvc": "0.1.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc