nodejs-polars
Advanced tools
Comparing version 0.8.2 to 0.8.3
@@ -8,5 +8,5 @@ /// <reference types="node" /> | ||
import { Writable } from "stream"; | ||
import { WriteCsvOptions, WriteIPCOptions, WriteParquetOptions, WriteAvroOptions, FillNullStrategy, JoinOptions } from "./types"; | ||
import { FillNullStrategy, JoinOptions, WriteAvroOptions, WriteCsvOptions, WriteIPCOptions, WriteParquetOptions } from "./types"; | ||
import { DataType } from "./datatypes"; | ||
import { ColumnSelection, ColumnsOrExpr, ValueOrArray, ExprOrString } from "./utils"; | ||
import { ColumnSelection, ColumnsOrExpr, ExprOrString, ValueOrArray } from "./utils"; | ||
import { Arithmetic, Deserialize, GroupByOps, Sample, Serialize } from "./shared_traits"; | ||
@@ -73,3 +73,2 @@ declare const inspect: unique symbol; | ||
* | ||
* | ||
* > df.writeJSON({format:"json"}) | ||
@@ -934,3 +933,2 @@ * `[ {"foo":1.0,"bar":"a"}, {"foo":2.0,"bar":"b"}, {"foo":3.0,"bar":"c"}]` | ||
/** | ||
* | ||
* Create a spreadsheet-style pivot table as a DataFrame. | ||
@@ -1284,3 +1282,2 @@ * | ||
/** | ||
* | ||
* @example | ||
@@ -1358,2 +1355,10 @@ * ``` | ||
/** | ||
* Converts dataframe object into a {@link TabularDataResource} | ||
*/ | ||
toDataResource(): TabularDataResource; | ||
/** | ||
* Converts dataframe object into HTML | ||
*/ | ||
toHTML(): string; | ||
/** | ||
* Converts dataframe object into column oriented javascript objects | ||
@@ -1613,3 +1618,16 @@ * @example | ||
} | ||
type DataResourceField = { | ||
name: string; | ||
type: string; | ||
}; | ||
/** | ||
* Tabular Data Resource from https://specs.frictionlessdata.io/schemas/tabular-data-resource.json, | ||
*/ | ||
type TabularDataResource = { | ||
data: any[]; | ||
schema: { | ||
fields: DataResourceField[]; | ||
}; | ||
}; | ||
/** | ||
* @ignore | ||
@@ -1616,0 +1634,0 @@ */ |
@@ -17,4 +17,6 @@ "use strict"; | ||
const utils_1 = require("./utils"); | ||
const html_1 = require("./html"); | ||
const functions_2 = require("./lazy/functions"); | ||
const inspect = Symbol.for("nodejs.util.inspect.custom"); | ||
const jupyterDisplay = Symbol.for("Jupyter.display"); | ||
function prepareOtherArg(anyValue) { | ||
@@ -31,2 +33,26 @@ if (series_1.Series.isSeries(anyValue)) { | ||
} | ||
function mapPolarsTypeToJSONSchema(colType) { | ||
const typeMapping = { | ||
Null: "null", | ||
Bool: "boolean", | ||
Int8: "integer", | ||
Int16: "integer", | ||
Int32: "integer", | ||
Int64: "integer", | ||
UInt8: "integer", | ||
UInt16: "integer", | ||
UInt32: "integer", | ||
UInt64: "integer", | ||
Float32: "number", | ||
Float64: "number", | ||
Date: "string", | ||
Datetime: "string", | ||
Utf8: "string", | ||
Categorical: "string", | ||
List: "array", | ||
Struct: "object", | ||
}; | ||
const dataType = colType.variant; | ||
return typeMapping[dataType] || "string"; | ||
} | ||
/** | ||
@@ -78,2 +104,20 @@ * @ignore | ||
}, | ||
/** | ||
* Return back text/html and application/vnd.dataresource+json representations | ||
* of the DataFrame. This is intended to be a simple view of the DataFrame | ||
* inside of notebooks. | ||
* | ||
* @returns Media bundle / mimetype keys for Jupyter frontends | ||
*/ | ||
[jupyterDisplay]() { | ||
let rows = 50; | ||
if (process.env.POLARS_FMT_MAX_ROWS) { | ||
rows = parseInt(process.env.POLARS_FMT_MAX_ROWS); | ||
} | ||
const limited = this.limit(rows); | ||
return { | ||
"application/vnd.dataresource+json": limited.toDataResource(), | ||
"text/html": limited.toHTML(), | ||
}; | ||
}, | ||
get schema() { | ||
@@ -334,3 +378,3 @@ return this.getColumns().reduce((acc, curr) => { | ||
sample(opts, frac, withReplacement = false, seed) { | ||
// rome-ignore lint/style/noArguments: <explanation> | ||
// biome-ignore lint/style/noArguments: <explanation> | ||
if (arguments.length === 0) { | ||
@@ -437,2 +481,30 @@ return wrap("sampleN", 1, withReplacement, false, seed); | ||
}, | ||
toHTML() { | ||
let htmlTable = "<table>"; | ||
// Add table headers | ||
htmlTable += "<thead><tr>"; | ||
this.getColumns().forEach((field) => { | ||
htmlTable += `<th>${(0, html_1.escapeHTML)(field.name)}</th>`; | ||
}); | ||
htmlTable += "</tr></thead>"; | ||
// Add table data | ||
htmlTable += "<tbody>"; | ||
this.toRecords().forEach((row) => { | ||
htmlTable += "<tr>"; | ||
this.getColumns().forEach((field) => { | ||
htmlTable += `<td>${(0, html_1.escapeHTML)(String(row[field.name]))}</td>`; | ||
}); | ||
htmlTable += "</tr>"; | ||
}); | ||
htmlTable += "</tbody></table>"; | ||
return htmlTable; | ||
}, | ||
toDataResource() { | ||
const data = this.toRecords(); | ||
const fields = this.getColumns().map((column) => ({ | ||
name: column.name, | ||
type: mapPolarsTypeToJSONSchema(column.dtype), | ||
})); | ||
return { data, schema: { fields } }; | ||
}, | ||
toObject() { | ||
@@ -624,2 +696,5 @@ return this.getColumns().reduce((acc, curr) => { | ||
has(target, p) { | ||
if (p === jupyterDisplay) { | ||
return true; | ||
} | ||
return target.columns.includes(p); | ||
@@ -626,0 +701,0 @@ }, |
@@ -27,7 +27,7 @@ import { Series } from "./series"; | ||
* - Horizontal: Stacks Series horizontally and fills with nulls if the lengths don't match. | ||
* | ||
* - Diagonal: Finds a union between the column schemas and fills missing column values with ``null``. | ||
* @example | ||
* > const df1 = pl.DataFrame({"a": [1], "b": [3]}) | ||
* > const df2 = pl.DataFrame({"a": [2], "b": [4]}) | ||
* > pl.concat([df1, df2]) | ||
* > const df1 = pl.DataFrame({"a": [1], "b": [3]}); | ||
* > const df2 = pl.DataFrame({"a": [2], "b": [4]}); | ||
* > pl.concat([df1, df2]); | ||
* shape: (2, 2) | ||
@@ -43,2 +43,31 @@ * ┌─────┬─────┐ | ||
* └─────┴─────┘ | ||
* | ||
* > const a = pl.DataFrame({ a: ["a", "b"], b: [1, 2] }); | ||
* > const b = pl.DataFrame({ c: [5, 6], d: [7, 8], e: [9, 10]}); | ||
* > pl.concat([a, b], { how: "horizontal" }); | ||
* | ||
* shape: (2, 5) | ||
* ┌─────┬─────┬─────┬─────┬──────┐ | ||
* │ a ┆ b ┆ c ┆ d ┆ e │ | ||
* │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ | ||
* │ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ | ||
* ╞═════╪═════╪═════╪═════╪══════╡ | ||
* │ a ┆ 1.0 ┆ 5.0 ┆ 7.0 ┆ 9.0 │ | ||
* │ b ┆ 2.0 ┆ 6.0 ┆ 8.0 ┆ 10.0 │ | ||
* └─────┴─────┴─────┴─────┴──────┘ | ||
* | ||
* > const df_d1 = pl.DataFrame({"a": [1], "b": [3]}); | ||
* > const df_d2 = pl.DataFrame({"a": [2], "c": [4]}); | ||
* > pl.concat([df_d1, df_d2], { how: "diagonal" }); | ||
* | ||
* shape: (2, 3) | ||
* ┌─────┬──────┬──────┐ | ||
* │ a ┆ b ┆ c │ | ||
* │ --- ┆ --- ┆ --- │ | ||
* │ i64 ┆ i64 ┆ i64 │ | ||
* ╞═════╪══════╪══════╡ | ||
* │ 1 ┆ 3 ┆ null │ | ||
* │ 2 ┆ null ┆ 4 │ | ||
* └─────┴──────┴──────┘ | ||
* | ||
*/ | ||
@@ -45,0 +74,0 @@ export declare function concat(items: Array<DataFrame>, options?: ConcatOptions): DataFrame; |
@@ -41,8 +41,15 @@ "use strict"; | ||
let df; | ||
if (how === "vertical") { | ||
df = items.reduce((acc, curr) => acc.vstack(curr)); | ||
switch (how) { | ||
case "vertical": | ||
df = items.reduce((acc, curr) => acc.vstack(curr)); | ||
break; | ||
case "horizontal": | ||
df = (0, dataframe_1._DataFrame)(polars_internal_1.default.horizontalConcat(items.map((i) => i.inner()))); | ||
break; | ||
case "diagonal": | ||
df = (0, dataframe_1._DataFrame)(polars_internal_1.default.diagonalConcat(items.map((i) => i.inner()))); | ||
break; | ||
default: | ||
throw new TypeError("unknown concat how option"); | ||
} | ||
else { | ||
df = (0, dataframe_1._DataFrame)(polars_internal_1.default.horizontalConcat(items.map((i) => i.inner()))); | ||
} | ||
return rechunk ? df.rechunk() : df; | ||
@@ -49,0 +56,0 @@ } |
@@ -93,2 +93,5 @@ import * as series from "./series"; | ||
export import anyHorizontal = lazy.anyHorizontal; | ||
export import minHorizontal = lazy.minHorizontal; | ||
export import maxHorizontal = lazy.maxHorizontal; | ||
export import sumHorizontal = lazy.sumHorizontal; | ||
export import spearmanRankCorr = lazy.spearmanRankCorr; | ||
@@ -95,0 +98,0 @@ export import tail = lazy.tail; |
@@ -76,7 +76,7 @@ "use strict"; | ||
pl.List = datatypes_1.DataType.List; | ||
// rome-ignore lint/suspicious/noShadowRestrictedNames: pl.Date | ||
// biome-ignore lint/suspicious/noShadowRestrictedNames: pl.Date | ||
pl.Date = datatypes_1.DataType.Date; | ||
pl.Datetime = datatypes_1.DataType.Datetime; | ||
pl.Time = datatypes_1.DataType.Time; | ||
// rome-ignore lint/suspicious/noShadowRestrictedNames: pl.Object | ||
// biome-ignore lint/suspicious/noShadowRestrictedNames: pl.Object | ||
pl.Object = datatypes_1.DataType.Object; | ||
@@ -130,2 +130,5 @@ pl.Null = datatypes_1.DataType.Null; | ||
pl.anyHorizontal = lazy.anyHorizontal; | ||
pl.minHorizontal = lazy.minHorizontal; | ||
pl.maxHorizontal = lazy.maxHorizontal; | ||
pl.sumHorizontal = lazy.sumHorizontal; | ||
pl.spearmanRankCorr = lazy.spearmanRankCorr; | ||
@@ -132,0 +135,0 @@ pl.tail = lazy.tail; |
@@ -169,2 +169,4 @@ "use strict"; | ||
let orient = options?.orient; | ||
const schema = options?.schema; | ||
const inferSchemaLength = options?.inferSchemaLength; | ||
let dataSeries; | ||
@@ -184,3 +186,3 @@ if (!data.length) { | ||
else if (data[0].constructor.name === "Object") { | ||
const df = polars_internal_1.default.fromRows(data, options); | ||
const df = polars_internal_1.default.fromRows(data, schema, inferSchemaLength); | ||
if (columns) { | ||
@@ -187,0 +189,0 @@ df.columns = columns; |
@@ -24,3 +24,3 @@ /// <reference types="node" /> | ||
commentChar: string; | ||
quotChar: string; | ||
quoteChar: string; | ||
nullValues: string | Array<string> | Record<string, string>; | ||
@@ -73,3 +73,3 @@ chunkSize: number; | ||
* @param options.commentChar - character that indicates the start of a comment line, for instance '#'. | ||
* @param options.quotChar -character that is used for csv quoting, default = ''. Set to null to turn special handling and escaping of quotes off. | ||
* @param options.quoteChar -character that is used for csv quoting, default = ''. Set to null to turn special handling and escaping of quotes off. | ||
* @param options.nullValues - Values to interpret as null values. You can provide a | ||
@@ -323,3 +323,3 @@ * - `string` -> all values encountered equal to this string will be null | ||
* @param options.commentChar - character that indicates the start of a comment line, for instance '#'. | ||
* @param options.quotChar -character that is used for csv quoting, default = ''. Set to null to turn special handling and escaping of quotes off. | ||
* @param options.quoteChar -character that is used for csv quoting, default = ''. Set to null to turn special handling and escaping of quotes off. | ||
* @param options.nullValues - Values to interpret as null values. You can provide a | ||
@@ -326,0 +326,0 @@ * - `string` -> all values encountered equal to this string will be null |
@@ -397,3 +397,3 @@ import { DataFrame } from "../dataframe"; | ||
*/ | ||
toJSON(): String; | ||
toJSON(): string; | ||
/** | ||
@@ -400,0 +400,0 @@ * Drop duplicate rows from this DataFrame. |
@@ -12,3 +12,3 @@ import * as dt from "./datetime"; | ||
import { Series } from "../../series"; | ||
import { Arithmetic, Comparison, Cumulative, Deserialize, Rolling, Round, Sample, Serialize } from "../../shared_traits"; | ||
import { Arithmetic, Comparison, Cumulative, Deserialize, Rolling, Round, Sample, Serialize, EwmOps } from "../../shared_traits"; | ||
import { FillNullStrategy, RankMethod } from "../../types"; | ||
@@ -18,3 +18,3 @@ /** | ||
*/ | ||
export interface Expr extends Rolling<Expr>, Arithmetic<Expr>, Comparison<Expr>, Cumulative<Expr>, Sample<Expr>, Round<Expr>, Serialize { | ||
export interface Expr extends Rolling<Expr>, Arithmetic<Expr>, Comparison<Expr>, Cumulative<Expr>, Sample<Expr>, Round<Expr>, EwmOps<Expr>, Serialize { | ||
/** @ignore */ | ||
@@ -21,0 +21,0 @@ _expr: any; |
@@ -180,2 +180,41 @@ "use strict"; | ||
}, | ||
ewmMean(opts, adjust, minPeriods, bias, ignoreNulls) { | ||
if (opts) { | ||
if (typeof opts === "number") { | ||
return wrap("ewmMean", opts, adjust ?? true, minPeriods ?? 1, bias ?? false, ignoreNulls ?? true); | ||
} | ||
else { | ||
return wrap("ewmMean", opts.alpha ?? 0.5, opts.adjust ?? true, opts.minPeriods ?? 1, opts.bias ?? false, opts.ignoreNulls ?? true); | ||
} | ||
} | ||
else { | ||
return wrap("ewmMean", 0.5, true, 1, false, true); | ||
} | ||
}, | ||
ewmStd(opts, adjust, minPeriods, bias, ignoreNulls) { | ||
if (opts) { | ||
if (typeof opts === "number") { | ||
return wrap("ewmStd", opts, adjust ?? true, minPeriods ?? 1, bias ?? false, ignoreNulls ?? true); | ||
} | ||
else { | ||
return wrap("ewmStd", opts.alpha ?? 0.5, opts.adjust ?? true, opts.minPeriods ?? 1, opts.bias ?? false, opts.ignoreNulls ?? true); | ||
} | ||
} | ||
else { | ||
return wrap("ewmStd", 0.5, true, 1, false, true); | ||
} | ||
}, | ||
ewmVar(opts, adjust, minPeriods, bias, ignoreNulls) { | ||
if (opts) { | ||
if (typeof opts === "number") { | ||
return wrap("ewmVar", opts, adjust ?? true, minPeriods ?? 1, bias ?? false, ignoreNulls ?? true); | ||
} | ||
else { | ||
return wrap("ewmVar", opts.alpha ?? 0.5, opts.adjust ?? true, opts.minPeriods ?? 1, opts.bias ?? false, opts.ignoreNulls ?? true); | ||
} | ||
} | ||
else { | ||
return wrap("ewmVar", 0.5, true, 1, false, true); | ||
} | ||
}, | ||
exclude(...columns) { | ||
@@ -182,0 +221,0 @@ return (0, exports._Expr)(_expr.exclude(columns.flat(2))); |
@@ -146,7 +146,22 @@ import { Expr } from "./expr"; | ||
/** | ||
* __Find the indexes that would sort the columns.__ | ||
* ___ | ||
* Argsort by multiple columns. The first column will be used for the ordering. | ||
* If there are duplicates in the first column, the second column will be used to determine the ordering | ||
* and so on. | ||
* Return the row indices that would sort the columns. | ||
* @param exprs Column(s) to arg sort by. Accepts expression input. | ||
* @param *more_exprs Additional columns to arg sort by, specified as positional arguments. | ||
* @param descending Sort in descending order. When sorting by multiple columns, can be specified per column by passing a sequence of booleans. | ||
* @example | ||
* ``` | ||
* const df = pl.DataFrame({"a": [0, 1, 1, 0], "b": [3, 2, 3, 2],}); | ||
* df.select(pl.argSortBy(pl.col("a"))); | ||
* shape: (4, 1) | ||
* ┌─────┐ | ||
* │ a │ | ||
* │ --- │ | ||
* │ u32 │ | ||
* ╞═════╡ | ||
* │ 0 │ | ||
* │ 3 │ | ||
* │ 1 │ | ||
* │ 2 │ | ||
* └─────┘ | ||
* ``` | ||
*/ | ||
@@ -354,33 +369,144 @@ export declare function argSortBy(exprs: Expr[] | string[], descending?: boolean | boolean[]): 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 │ | ||
└───────┴───────┴─────┴───────┘ | ||
/** | ||
* Compute the bitwise AND horizontally across columns. | ||
* @param *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. | ||
* | ||
* @example | ||
* ``` | ||
* >>> const df = pl.DataFrame( | ||
* { | ||
* "a": [false, false, true, true], | ||
* "b": [false, true, null, true], | ||
* "c": ["w", "x", "y", "z"], | ||
* } | ||
* ) | ||
* >>> df.withColumns(pl.allHorizontal([pl.col("a"), pl.col("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; | ||
/** | ||
* Compute the bitwise OR horizontally across columns. | ||
* @param *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. | ||
* @example | ||
* ``` | ||
* >>> 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 │ | ||
* └───────┴───────┴─────┴───────┘ | ||
* ``` | ||
*/ | ||
export declare function anyHorizontal(exprs: ExprOrString | ExprOrString[]): Expr; | ||
/** | ||
* Get the maximum value horizontally across columns. | ||
* @param *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. | ||
* @example | ||
* ``` | ||
* >>> const df = pl.DataFrame( | ||
* ... { | ||
* ... "a": [1, 8, 3], | ||
* ... "b": [4, 5, null], | ||
* ... "c": ["x", "y", "z"], | ||
* ... } | ||
* ... ) | ||
* >>> df.withColumns(pl.maxHorizontal(pl.col("a"), pl.col("b"))) | ||
* shape: (3, 4) | ||
* ┌─────┬──────┬─────┬─────┐ | ||
* │ a ┆ b ┆ c ┆ max │ | ||
* │ --- ┆ --- ┆ --- ┆ --- │ | ||
* │ i64 ┆ i64 ┆ str ┆ i64 │ | ||
* ╞═════╪══════╪═════╪═════╡ | ||
* │ 1 ┆ 4 ┆ x ┆ 4 │ | ||
* │ 8 ┆ 5 ┆ y ┆ 8 │ | ||
* │ 3 ┆ null ┆ z ┆ 3 │ | ||
* └─────┴──────┴─────┴─────┘ | ||
* ``` | ||
*/ | ||
export declare function maxHorizontal(exprs: ExprOrString | ExprOrString[]): Expr; | ||
/** | ||
* Get the minimum value horizontally across columns. | ||
* @param *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. | ||
* @example | ||
* ``` | ||
* >>> const df = pl.DataFrame( | ||
* ... { | ||
* ... "a": [1, 8, 3], | ||
* ... "b": [4, 5, null], | ||
* ... "c": ["x", "y", "z"], | ||
* ... } | ||
* ... ) | ||
* >>> df.withColumns(pl.minHorizontal(pl.col("a"), pl.col("b"))) | ||
* shape: (3, 4) | ||
* ┌─────┬──────┬─────┬─────┐ | ||
* │ a ┆ b ┆ c ┆ min │ | ||
* │ --- ┆ --- ┆ --- ┆ --- │ | ||
* │ i64 ┆ i64 ┆ str ┆ i64 │ | ||
* ╞═════╪══════╪═════╪═════╡ | ||
* │ 1 ┆ 4 ┆ x ┆ 1 │ | ||
* │ 8 ┆ 5 ┆ y ┆ 5 │ | ||
* │ 3 ┆ null ┆ z ┆ 3 │ | ||
* └─────┴──────┴─────┴─────┘ | ||
* ``` | ||
*/ | ||
export declare function minHorizontal(exprs: ExprOrString | ExprOrString[]): Expr; | ||
/** | ||
* Sum all values horizontally across columns. | ||
* @param *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. | ||
* @example | ||
* ``` | ||
* >>> const df = pl.DataFrame( | ||
* ... { | ||
* ... "a": [1, 8, 3], | ||
* ... "b": [4, 5, null], | ||
* ... "c": ["x", "y", "z"], | ||
* ... } | ||
* ... ) | ||
* >>> df.withColumns(pl.sumHorizontal(pl.col("a"), ol.col("b"))) | ||
* shape: (3, 4) | ||
* ┌─────┬──────┬─────┬──────┐ | ||
* │ a ┆ b ┆ c ┆ sum │ | ||
* │ --- ┆ --- ┆ --- ┆ --- │ | ||
* │ i64 ┆ i64 ┆ str ┆ i64 │ | ||
* ╞═════╪══════╪═════╪══════╡ | ||
* │ 1 ┆ 4 ┆ x ┆ 5 │ | ||
* │ 8 ┆ 5 ┆ y ┆ 13 │ | ||
* │ 3 ┆ null ┆ z ┆ null │ | ||
* └─────┴──────┴─────┴──────┘ | ||
* ``` | ||
*/ | ||
export declare function sumHorizontal(exprs: ExprOrString | ExprOrString[]): Expr; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
exports.sumHorizontal = exports.minHorizontal = exports.maxHorizontal = 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"); | ||
@@ -170,7 +170,22 @@ const series_1 = require("../series"); | ||
/** | ||
* __Find the indexes that would sort the columns.__ | ||
* ___ | ||
* Argsort by multiple columns. The first column will be used for the ordering. | ||
* If there are duplicates in the first column, the second column will be used to determine the ordering | ||
* and so on. | ||
* Return the row indices that would sort the columns. | ||
* @param exprs Column(s) to arg sort by. Accepts expression input. | ||
* @param *more_exprs Additional columns to arg sort by, specified as positional arguments. | ||
* @param descending Sort in descending order. When sorting by multiple columns, can be specified per column by passing a sequence of booleans. | ||
* @example | ||
* ``` | ||
* const df = pl.DataFrame({"a": [0, 1, 1, 0], "b": [3, 2, 3, 2],}); | ||
* df.select(pl.argSortBy(pl.col("a"))); | ||
* shape: (4, 1) | ||
* ┌─────┐ | ||
* │ a │ | ||
* │ --- │ | ||
* │ u32 │ | ||
* ╞═════╡ | ||
* │ 0 │ | ||
* │ 3 │ | ||
* │ 1 │ | ||
* │ 2 │ | ||
* └─────┘ | ||
* ``` | ||
*/ | ||
@@ -437,31 +452,30 @@ function argSortBy(exprs, descending = false) { | ||
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 │ | ||
└───────┴───────┴─────┴───────┘ | ||
/** | ||
* Compute the bitwise AND horizontally across columns. | ||
* @param *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. | ||
* | ||
* @example | ||
* ``` | ||
* >>> const df = pl.DataFrame( | ||
* { | ||
* "a": [false, false, true, true], | ||
* "b": [false, true, null, true], | ||
* "c": ["w", "x", "y", "z"], | ||
* } | ||
* ) | ||
* >>> df.withColumns(pl.allHorizontal([pl.col("a"), pl.col("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 │ | ||
* └───────┴───────┴─────┴───────┘ | ||
* ``` | ||
*/ | ||
@@ -474,33 +488,30 @@ function 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 │ | ||
└───────┴───────┴─────┴───────┘ | ||
*/ | ||
/** | ||
* Compute the bitwise OR horizontally across columns. | ||
* @param *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. | ||
* @example | ||
* ``` | ||
* >>> 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) { | ||
@@ -512,2 +523,101 @@ exprs = Array.isArray(exprs) ? exprs : [exprs]; | ||
exports.anyHorizontal = anyHorizontal; | ||
/** | ||
* Get the maximum value horizontally across columns. | ||
* @param *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. | ||
* @example | ||
* ``` | ||
* >>> const df = pl.DataFrame( | ||
* ... { | ||
* ... "a": [1, 8, 3], | ||
* ... "b": [4, 5, null], | ||
* ... "c": ["x", "y", "z"], | ||
* ... } | ||
* ... ) | ||
* >>> df.withColumns(pl.maxHorizontal(pl.col("a"), pl.col("b"))) | ||
* shape: (3, 4) | ||
* ┌─────┬──────┬─────┬─────┐ | ||
* │ a ┆ b ┆ c ┆ max │ | ||
* │ --- ┆ --- ┆ --- ┆ --- │ | ||
* │ i64 ┆ i64 ┆ str ┆ i64 │ | ||
* ╞═════╪══════╪═════╪═════╡ | ||
* │ 1 ┆ 4 ┆ x ┆ 4 │ | ||
* │ 8 ┆ 5 ┆ y ┆ 8 │ | ||
* │ 3 ┆ null ┆ z ┆ 3 │ | ||
* └─────┴──────┴─────┴─────┘ | ||
* ``` | ||
*/ | ||
function maxHorizontal(exprs) { | ||
exprs = Array.isArray(exprs) ? exprs : [exprs]; | ||
exprs = (0, utils_1.selectionToExprList)(exprs); | ||
return (0, expr_1._Expr)(polars_internal_1.default.maxHorizontal(exprs)); | ||
} | ||
exports.maxHorizontal = maxHorizontal; | ||
/** | ||
* Get the minimum value horizontally across columns. | ||
* @param *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. | ||
* @example | ||
* ``` | ||
* >>> const df = pl.DataFrame( | ||
* ... { | ||
* ... "a": [1, 8, 3], | ||
* ... "b": [4, 5, null], | ||
* ... "c": ["x", "y", "z"], | ||
* ... } | ||
* ... ) | ||
* >>> df.withColumns(pl.minHorizontal(pl.col("a"), pl.col("b"))) | ||
* shape: (3, 4) | ||
* ┌─────┬──────┬─────┬─────┐ | ||
* │ a ┆ b ┆ c ┆ min │ | ||
* │ --- ┆ --- ┆ --- ┆ --- │ | ||
* │ i64 ┆ i64 ┆ str ┆ i64 │ | ||
* ╞═════╪══════╪═════╪═════╡ | ||
* │ 1 ┆ 4 ┆ x ┆ 1 │ | ||
* │ 8 ┆ 5 ┆ y ┆ 5 │ | ||
* │ 3 ┆ null ┆ z ┆ 3 │ | ||
* └─────┴──────┴─────┴─────┘ | ||
* ``` | ||
*/ | ||
function minHorizontal(exprs) { | ||
exprs = Array.isArray(exprs) ? exprs : [exprs]; | ||
exprs = (0, utils_1.selectionToExprList)(exprs); | ||
return (0, expr_1._Expr)(polars_internal_1.default.minHorizontal(exprs)); | ||
} | ||
exports.minHorizontal = minHorizontal; | ||
/** | ||
* Sum all values horizontally across columns. | ||
* @param *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. | ||
* @example | ||
* ``` | ||
* >>> const df = pl.DataFrame( | ||
* ... { | ||
* ... "a": [1, 8, 3], | ||
* ... "b": [4, 5, null], | ||
* ... "c": ["x", "y", "z"], | ||
* ... } | ||
* ... ) | ||
* >>> df.withColumns(pl.sumHorizontal(pl.col("a"), ol.col("b"))) | ||
* shape: (3, 4) | ||
* ┌─────┬──────┬─────┬──────┐ | ||
* │ a ┆ b ┆ c ┆ sum │ | ||
* │ --- ┆ --- ┆ --- ┆ --- │ | ||
* │ i64 ┆ i64 ┆ str ┆ i64 │ | ||
* ╞═════╪══════╪═════╪══════╡ | ||
* │ 1 ┆ 4 ┆ x ┆ 5 │ | ||
* │ 8 ┆ 5 ┆ y ┆ 13 │ | ||
* │ 3 ┆ null ┆ z ┆ null │ | ||
* └─────┴──────┴─────┴──────┘ | ||
* ``` | ||
*/ | ||
function sumHorizontal(exprs) { | ||
exprs = Array.isArray(exprs) ? exprs : [exprs]; | ||
exprs = (0, utils_1.selectionToExprList)(exprs); | ||
return (0, expr_1._Expr)(polars_internal_1.default.sumHorizontal(exprs)); | ||
} | ||
exports.sumHorizontal = sumHorizontal; | ||
// // export function collect_all() {} | ||
@@ -514,0 +624,0 @@ // // export function all() {} // fold |
@@ -7,3 +7,3 @@ import { DataType, Optional } from "../datatypes"; | ||
import { SeriesStructFunctions } from "./struct"; | ||
import { Arithmetic, Comparison, Cumulative, Deserialize, Rolling, Round, Sample, Serialize } from "../shared_traits"; | ||
import { Arithmetic, Comparison, Cumulative, Deserialize, Rolling, Round, Sample, Serialize, EwmOps } from "../shared_traits"; | ||
import { InterpolationMethod, RankMethod } from "../types"; | ||
@@ -14,3 +14,3 @@ declare const inspect: unique symbol; | ||
*/ | ||
export interface Series extends ArrayLike<any>, Rolling<Series>, Arithmetic<Series>, Comparison<Series>, Cumulative<Series>, Round<Series>, Sample<Series>, Serialize { | ||
export interface Series extends ArrayLike<any>, Rolling<Series>, Arithmetic<Series>, Comparison<Series>, Cumulative<Series>, Round<Series>, Sample<Series>, EwmOps<Series>, Serialize { | ||
inner(): any; | ||
@@ -17,0 +17,0 @@ name: string; |
@@ -225,2 +225,11 @@ "use strict"; | ||
}, | ||
ewmMean(...args) { | ||
return expr_op("ewmMean", ...args); | ||
}, | ||
ewmStd(...args) { | ||
return expr_op("ewmStd", ...args); | ||
}, | ||
ewmVar(...args) { | ||
return expr_op("ewmVar", ...args); | ||
}, | ||
explode() { | ||
@@ -532,3 +541,3 @@ return wrap("explode"); | ||
sample(opts, frac, withReplacement = false, seed) { | ||
// rome-ignore lint/style/noArguments: <explanation> | ||
// biome-ignore lint/style/noArguments: <explanation> | ||
if (arguments.length === 0) { | ||
@@ -535,0 +544,0 @@ return wrap("sampleN", 1, withReplacement, false, seed); |
@@ -295,6 +295,9 @@ /// <reference types="node" /> | ||
* @param center - Set the labels at the center of the window | ||
* @param ddof | ||
* "Delta Degrees of Freedom”: the divisor used in the calculation is N - ddof, where N represents the number of elements. | ||
* By default ddof is 1. | ||
* @category Rolling | ||
*/ | ||
rollingStd(options: RollingOptions): T; | ||
rollingStd(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): T; | ||
rollingStd(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean, ddof?: number): T; | ||
/** | ||
@@ -332,6 +335,9 @@ * __Apply a rolling sum (moving sum) over the values in this Series.__ | ||
* @param center - Set the labels at the center of the window | ||
* @param ddof | ||
* "Delta Degrees of Freedom”: the divisor used in the calculation is N - ddof, where N represents the number of elements. | ||
* By default ddof is 1. | ||
* @category Rolling | ||
*/ | ||
rollingVar(options: RollingOptions): T; | ||
rollingVar(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean): T; | ||
rollingVar(windowSize: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean, ddof?: number): T; | ||
/** | ||
@@ -356,3 +362,3 @@ * Compute a rolling median | ||
rollingQuantile(options: RollingQuantileOptions): T; | ||
rollingQuantile(quantile: number, interpolation?: InterpolationMethod, windowSize?: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean, by?: String, closed?: ClosedWindow): T; | ||
rollingQuantile(quantile: number, interpolation?: InterpolationMethod, windowSize?: number, weights?: Array<number>, minPeriods?: Array<number>, center?: boolean, by?: string, closed?: ClosedWindow): T; | ||
/** | ||
@@ -1139,1 +1145,121 @@ * Compute a rolling skew | ||
} | ||
/*** | ||
* Exponentially-weighted operations that can be applied to a Series and Expr | ||
*/ | ||
export interface EwmOps<T> { | ||
/** | ||
* Exponentially-weighted moving average. | ||
* | ||
* @param alpha Specify smoothing factor alpha directly, :math:`0 < \alpha \leq 1`. | ||
* @param adjust Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings | ||
* - When ``adjust: true`` the EW function is calculated using weights :math:`w_i = (1 - \alpha)^i` | ||
* - When ``adjust=false`` the EW function is calculated recursively | ||
* @param bias When ``bias: false``, apply a correction to make the estimate statistically unbiased. | ||
* @param minPeriods Minimum number of observations in window required to have a value (otherwise result is null). | ||
* @param ignoreNulls Ignore missing values when calculating weights. | ||
* - When ``ignoreNulls: false`` (default), weights are based on absolute positions. | ||
* - When ``ignoreNulls: true``, weights are based on relative positions. | ||
* @returns Expr that evaluates to a float 64 Series. | ||
* @examples | ||
* ``` | ||
* > const df = pl.DataFrame({a: [1, 2, 3]}); | ||
* > df.select(pl.col("a").ewmMean()) | ||
* shape: (3, 1) | ||
* ┌──────────┐ | ||
* │ a │ | ||
* | --- │ | ||
* │ f64 │ | ||
* ╞══════════╡ | ||
* │ 1.0 │ | ||
* │ 1.666667 │ | ||
* │ 2.428571 │ | ||
* └──────────┘ | ||
* ``` | ||
*/ | ||
ewmMean(): T; | ||
ewmMean(alpha?: number, adjust?: boolean, minPeriods?: number, bias?: boolean, ignoreNulls?: boolean): T; | ||
ewmMean(opts: { | ||
alpha?: number; | ||
adjust?: boolean; | ||
minPeriods?: number; | ||
bias?: boolean; | ||
ignoreNulls?: boolean; | ||
}): T; | ||
/** | ||
* Exponentially-weighted standard deviation. | ||
* | ||
* @param alpha Specify smoothing factor alpha directly, :math:`0 < \alpha \leq 1`. | ||
* @param adjust Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings | ||
* - When ``adjust: true`` the EW function is calculated using weights :math:`w_i = (1 - \alpha)^i` | ||
* - When ``adjust: false`` the EW function is calculated recursively | ||
* @param minPeriods Minimum number of observations in window required to have a value (otherwise result is null). | ||
* @param bias When ``bias: false``, apply a correction to make the estimate statistically unbiased. | ||
* @param ignoreNulls Ignore missing values when calculating weights. | ||
* - When ``ignoreNulls: false`` (default), weights are based on absolute positions. | ||
* For example, the weights of :math:`x_0` and :math:`x_2` used in calculating the final weighted average of | ||
* - When ``ignoreNulls: true``, weights are based on relative positions. | ||
* @returns Expr that evaluates to a float 64 Series. | ||
* @examples | ||
* ``` | ||
* > const df = pl.DataFrame({a: [1, 2, 3]}); | ||
* > df.select(pl.col("a").ewmStd()) | ||
* shape: (3, 1) | ||
* ┌──────────┐ | ||
* │ a │ | ||
* | --- │ | ||
* │ f64 │ | ||
* ╞══════════╡ | ||
* │ 0.0 │ | ||
* │ 0.707107 │ | ||
* │ 0.963624 │ | ||
* └──────────┘ | ||
* ``` | ||
*/ | ||
ewmStd(): T; | ||
ewmStd(alpha?: number, adjust?: boolean, minPeriods?: number, bias?: boolean, ignoreNulls?: boolean): T; | ||
ewmStd(opts: { | ||
alpha?: number; | ||
adjust?: boolean; | ||
minPeriods?: number; | ||
bias?: boolean; | ||
ignoreNulls?: boolean; | ||
}): T; | ||
/** | ||
* Exponentially-weighted variance. | ||
* | ||
* @param alpha Specify smoothing factor alpha directly, :math:`0 < \alpha \leq 1`. | ||
* @param adjust Divide by decaying adjustment factor in beginning periods to account for imbalance in relative weightings | ||
* - When ``adjust: true`` the EW function is calculated using weights :math:`w_i = (1 - \alpha)^i` | ||
* - When ``adjust: false`` the EW function is calculated recursively | ||
* @param minPeriods Minimum number of observations in window required to have a value (otherwise result is null). | ||
* @param bias When ``bias: false``, apply a correction to make the estimate statistically unbiased. | ||
* @param ignoreNulls Ignore missing values when calculating weights. | ||
* - When ``ignoreNulls: false`` (default), weights are based on absolute positions. | ||
* - When ``ignoreNulls=true``, weights are based on relative positions. | ||
* @returns Expr that evaluates to a float 64 Series. | ||
* @examples | ||
* ``` | ||
* > const df = pl.DataFrame({a: [1, 2, 3]}); | ||
* > df.select(pl.col("a").ewmVar()) | ||
* shape: (3, 1) | ||
* ┌──────────┐ | ||
* │ a │ | ||
* | --- │ | ||
* │ f64 │ | ||
* ╞══════════╡ | ||
* │ 0.0 │ | ||
* │ 0.5 │ | ||
* │ 0.928571 │ | ||
* └──────────┘ | ||
* ``` | ||
*/ | ||
ewmVar(): T; | ||
ewmVar(alpha?: number, adjust?: boolean, minPeriods?: number, bias?: boolean, ignoreNulls?: boolean): T; | ||
ewmVar(opts: { | ||
alpha?: number; | ||
adjust?: boolean; | ||
minPeriods?: number; | ||
bias?: boolean; | ||
ignoreNulls?: boolean; | ||
}): T; | ||
} |
@@ -18,3 +18,3 @@ /** | ||
rechunk?: boolean; | ||
how?: "vertical" | "horizontal"; | ||
how?: "vertical" | "horizontal" | "diagonal"; | ||
} | ||
@@ -153,2 +153,3 @@ /** | ||
center?: boolean; | ||
ddof?: number; | ||
} | ||
@@ -155,0 +156,0 @@ /** |
{ | ||
"name": "nodejs-polars", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"repository": "https://github.com/pola-rs/nodejs-polars.git", | ||
@@ -58,9 +58,9 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@biomejs/biome": "^1.0.0", | ||
"@biomejs/biome": "^1.1.2", | ||
"@napi-rs/cli": "^2.16.3", | ||
"@types/chance": "^1.1.4", | ||
"@types/jest": "^29.5.4", | ||
"@types/node": "^20.5.9", | ||
"@types/node": "^20.6.0", | ||
"chance": "^1.1.11", | ||
"jest": "^29.6.4", | ||
"jest": "^29.7.0", | ||
"source-map-support": "^0.5.21", | ||
@@ -77,12 +77,12 @@ "ts-jest": "^29.1.1", | ||
"optionalDependencies": { | ||
"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" | ||
"nodejs-polars-win32-x64-msvc": "0.8.3", | ||
"nodejs-polars-darwin-x64": "0.8.3", | ||
"nodejs-polars-linux-x64-gnu": "0.8.3", | ||
"nodejs-polars-darwin-arm64": "0.8.3", | ||
"nodejs-polars-linux-arm64-gnu": "0.8.3", | ||
"nodejs-polars-linux-arm64-musl": "0.8.3", | ||
"nodejs-polars-android-arm64": "0.8.3", | ||
"nodejs-polars-win32-ia32-msvc": "0.8.3", | ||
"nodejs-polars-linux-x64-musl": "0.8.3" | ||
} | ||
} |
# Polars | ||
Polars: Blazingly fast DataFrames in Rust, Python, Node.js, R and SQL | ||
[![rust docs](https://docs.rs/polars/badge.svg)](https://docs.rs/polars/latest/polars/) | ||
@@ -66,3 +68,3 @@ [![Build and test](https://github.com/pola-rs/polars/workflows/Build%20and%20test/badge.svg)](https://github.com/pola-rs/polars/actions) | ||
... pl.lit("fruits").alias("literal_string_fruits"), | ||
... pl.col("B").filter(pl.col("cars").eq(lit("beetle"))).sum(), | ||
... pl.col("B").filter(pl.col("cars").eq(pl.lit("beetle"))).sum(), | ||
... pl.col("A").filter(pl.col("B").gt(2)).sum().over("cars").alias("sum_A_by_cars"), | ||
@@ -119,2 +121,39 @@ ... pl.col("A").sum().over("fruits").alias("sum_A_by_fruits"), | ||
## Deno | ||
In Deno modules you can import polars straight from `npm`: | ||
```typescript | ||
import pl from "npm:nodejs-polars"; | ||
``` | ||
With Deno 1.37, you can use the `display` function to display a `DataFrame` in the notebook: | ||
```typescript | ||
import pl from "npm:nodejs-polars"; | ||
import { display } from "https://deno.land/x/display@v1.1.1/mod.ts"; | ||
let response = await fetch( | ||
"https://cdn.jsdelivr.net/npm/world-atlas@1/world/110m.tsv", | ||
); | ||
let data = await response.text(); | ||
let df = pl.readCSV(data, { sep: "\t" }); | ||
await display(df) | ||
``` | ||
With Deno 1.38, you only have to make the dataframe be the last expression in the cell: | ||
```typescript | ||
import pl from "npm:nodejs-polars"; | ||
let response = await fetch( | ||
"https://cdn.jsdelivr.net/npm/world-atlas@1/world/110m.tsv", | ||
); | ||
let data = await response.text(); | ||
let df = pl.readCSV(data, { sep: "\t" }); | ||
df | ||
``` | ||
<img width="510" alt="image" src="https://github.com/pola-rs/nodejs-polars/assets/836375/90cf7bf4-7478-4919-b297-f8eb6a16196f"> | ||
___ | ||
@@ -121,0 +160,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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
467362
67
12749
212
9