nodejs-polars
Version:
Polars: Blazingly fast DataFrames in Rust, Python, Node.js, R and SQL
78 lines (77 loc) • 3.17 kB
TypeScript
import { type DataFrame } from "./dataframe";
import { type LazyDataFrame } from "./lazy/dataframe";
import { type Series } from "./series";
import type { ConcatOptions } from "./types";
/**
* _Repeat a single value n times and collect into a Series._
* @param value - Value to repeat.
* @param n - Number of repeats
* @param name - Optional name of the Series
* @example
*
* ```
*
* > const s = pl.repeat("a", 5)
* > s.toArray()
* ["a", "a", "a", "a", "a"]
*
* ```
*/
export declare function repeat<V>(value: V, n: number, name?: string): Series;
/**
* Aggregate all the Dataframes/Series in a List of DataFrames/Series to a single DataFrame/Series.
* @param items DataFrames/Series/LazyFrames to concatenate.
* @param options.rechunk rechunk the final DataFrame/Series.
* @param options.how Only used if the items are DataFrames. *Defaults to 'vertical'*
* - Vertical: Applies multiple `vstack` operations.
* - 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]);
* shape: (2, 2)
* ┌─────┬─────┐
* │ a ┆ b │
* │ --- ┆ --- │
* │ i64 ┆ i64 │
* ╞═════╪═════╡
* │ 1 ┆ 3 │
* ├╌╌╌╌╌┼╌╌╌╌╌┤
* │ 2 ┆ 4 │
* └─────┴─────┘
*
* > 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 │
* └─────┴──────┴──────┘
*
*/
export declare function concat(items: Array<DataFrame>, options?: ConcatOptions): DataFrame;
export declare function concat(items: Array<Series>, options?: {
rechunk: boolean;
}): Series;
export declare function concat(items: Array<LazyDataFrame>, options?: ConcatOptions): LazyDataFrame;