### Complete SQL Query Example Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/07-sql.md Demonstrates creating a DataFrame, setting up an SQL context, and executing multiple SQL queries for data analysis. Use `eager: true` to get immediate results. ```typescript import pl from 'nodejs-polars'; // Create sample data const moviesData = [ { title: 'The Godfather', year: 1972, budget: 6_000_000, gross: 134_821_952, imdb: 9.2 }, { title: 'The Dark Knight', year: 2008, budget: 185_000_000, gross: 533_316_061, imdb: 9.0 }, { title: 'Schindler\'s List', year: 1993, budget: 22_000_000, gross: 96_067_179, imdb: 8.9 }, { title: 'Pulp Fiction', year: 1994, budget: 8_000_000, gross: 107_930_000, imdb: 8.9 }, { title: 'The Shawshank Redemption', year: 1994, budget: 25_000_000, gross: 28_341_469, imdb: 9.3 } ]; const df = pl.readRecords(moviesData); // Create SQL context const ctx = pl.SQLContext({ films: df }); // Query 1: Find high-rated films const highRated = ctx.execute( ` SELECT title, year, imdb FROM films WHERE imdb > 9 ORDER BY imdb DESC `, { eager: true } ); console.log(highRated); // Query 2: Profitability analysis const profitable = ctx.execute( ` SELECT title, (gross - budget) as profit, ROUND((100.0 * (gross - budget) / budget), 2) as roi_percent FROM films WHERE gross > budget ORDER BY profit DESC `, { eager: true } ); console.log(profitable); // Query 3: Decade analysis const byDecade = ctx.execute( ` SELECT CAST((year / 10) * 10 AS INT) as decade, COUNT(*) as count, AVG(imdb) as avg_rating, SUM(gross) as total_gross FROM films GROUP BY decade ORDER BY decade DESC `, { eager: true } ); console.log(byDecade); ``` -------------------------------- ### Install project dependencies Source: https://github.com/pola-rs/nodejs-polars/blob/main/CONTRIBUTING.md After cloning the repository, install all necessary project dependencies using yarn. ```bash yarn install ``` -------------------------------- ### Chaining Example Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/configuration.md Demonstrates the chainability of Configuration API methods for fluent usage. ```APIDOC ## Chaining All methods return Config for fluent chaining: ### Example ```typescript import pl from 'nodejs-polars'; pl.Config .setAsciiTables(true) .setTblRows(10) .setTblCols(5) .setThousandsSeparator(true); ``` ``` -------------------------------- ### Schema Example Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/types.md Illustrates creating a schema object and using it to initialize a DataFrame. ```typescript const schema: Schema = { name: pl.String, age: pl.Int32, created: pl.Datetime('ns', 'UTC') }; const df = pl.DataFrame(data, { schema }); ``` -------------------------------- ### Installing Node.js Polars Source: https://github.com/pola-rs/nodejs-polars/blob/main/README.md Provides installation commands for nodejs-polars using popular package managers like yarn, npm, and Bun. It also notes that frequent updates are common. ```sh $ yarn add nodejs-polars # yarn $ npm i -s nodejs-polars # npm $ bun i -D nodejs-polars # Bun ``` -------------------------------- ### Datetime Examples Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/types.md Demonstrates creating Datetime types with different time units and timezones. ```typescript pl.Datetime(); ``` ```typescript pl.Datetime('ns'); ``` ```typescript pl.Datetime('us', 'America/New_York'); ``` -------------------------------- ### Example: Compute Dot Product Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Demonstrates calculating the dot product of two Series. ```typescript const s1 = pl.Series([1, 2, 3]); const s2 = pl.Series([4, 5, 6]); s1.dot(s2); // 1*4 + 2*5 + 3*6 = 32 ``` -------------------------------- ### Decimal Type Example Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/types.md Shows how to instantiate a Decimal type with specified precision and scale. ```typescript pl.Decimal(10, 2); // 10 digits total, 2 after decimal ``` -------------------------------- ### Field Class Example Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/types.md Demonstrates how to create a `Field` instance and define a schema using it. ```typescript const field = new Field('my_column', pl.Int64); const schema = { my_column: pl.Int64 }; ``` -------------------------------- ### Series Constructor Examples Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Illustrates practical usage of the Series constructor with various parameter combinations. ```typescript const s = pl.Series('my_series', [1, 2, 3]); const s = pl.Series([1, 2, 3]); // name defaults to '' const s = pl.Series('nums', [1, 2, 3], pl.Float64); const s = pl.Series({ name: 'data', values: [1, 2, 3] }); ``` -------------------------------- ### Clone the nodejs-polars repository Source: https://github.com/pola-rs/nodejs-polars/blob/main/CONTRIBUTING.md Fork the repository and then clone it from your fork to start development. ```bash git clone https://github.com//nodejs-polars.git ``` -------------------------------- ### Example: Fill Null Values Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Demonstrates filling null values using 'forward' and 'min' strategies. ```typescript s.fillNull('forward'); // forward fill s.fillNull('min'); // fill with minimum value ``` -------------------------------- ### Example: Explode Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Shows how to use `explode` to transform a Series of lists into a flat Series. ```typescript const s = pl.Series([[1, 2], [3, 4]]); s.explode(); // [1, 2, 3, 4] ``` -------------------------------- ### sample() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/01-dataframe.md Get a random sample of rows from the DataFrame, with options for number of samples, fraction, replacement, and seed. ```APIDOC ## sample() ### Description Random sample of rows. ### Method ```typescript sample(options?: { n?: number, fraction?: number, withReplacement?: boolean, seed?: number }): DataFrame ``` ### Parameters #### Path Parameters - **n** (number) - Optional - Number of rows to sample - **fraction** (number) - Optional - Fraction of rows to sample (0-1) - **withReplacement** (boolean) - Optional - Sample with replacement; default false - **seed** (number) - Optional - Random seed ### Response #### Success Response (200) - **DataFrame** - Sampled DataFrame. ``` -------------------------------- ### IO Operations Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Provides examples for reading from and writing to various file formats like CSV, JSON, and Parquet. ```APIDOC ## IO Operations ### Description Provides examples for reading from and writing to various file formats like CSV, JSON, and Parquet. ### IO Operations ```typescript // Read CSV const df = pl.readCSV('data.csv'); const df = pl.readCSV('col1,col2\n1,a\n2,b'); // Read JSON const df = pl.readJSON('data.json'); // Read Parquet const df = pl.readParquet('data.parquet'); // Write CSV df.writeCSV('output.csv'); const csv = df.writeCSV(); // Write Parquet df.writeParquet('output.parquet'); ``` ``` -------------------------------- ### groupBy() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Starts a groupby operation on a LazyDataFrame, allowing for subsequent aggregations. ```APIDOC ## groupBy() ### Description Starts a groupby operation on a LazyDataFrame, allowing for subsequent aggregations. ### Method Signature ```typescript groupBy(...columns: (string | Expr)[]): LazyGroupBy groupBy(columns: (string | Expr)[]): LazyGroupBy ``` ### Parameters - **columns** ((string | Expr)[]) - Required - Column names or expressions to group by ### Returns LazyGroupBy object. ### Example ```typescript ldf.groupBy('group').agg([pl.col('value').sum()]); ldf.groupBy('a', 'b').agg(pl.col('c').mean()); ``` ``` -------------------------------- ### intRange() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/08-utilities.md Creates a range of integers. It supports specifying start, end, step, and an option to materialize the range into a Series. ```APIDOC ## intRange() ### Description Creates a range of integers. ### Signature ```typescript intRange(start: number, end: number, step?: number, eager?: boolean): Expr | Series ``` ### Parameters #### Path Parameters - **start** (number) - Required - Start value (inclusive) - **end** (number) - Required - End value (exclusive) - **step** (number) - Optional - Increment step; default 1 - **eager** (boolean) - Optional - Materialize to Series; default false ### Returns Expr or Series if eager=true. ### Examples ```typescript pl.intRange(0, 5); pl.intRange(0, 10, 2); pl.intRange(5, 0, -1); pl.intRange(0, 5, 1, true); ``` ``` -------------------------------- ### Accessing Polars Library Version Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Shows how to access the currently installed version of the nodejs-polars library. ```typescript import pl from 'nodejs-polars'; console.log(pl.version); ``` -------------------------------- ### SQL Error Handling Example Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/07-sql.md Demonstrates how to catch and log SQL parse errors using a try-catch block. This is useful for debugging invalid SQL syntax. ```typescript try { const result = ctx.execute('SELEC * FROM table', { eager: true }); } catch (e) { console.error('SQL Error:', e.message); } ``` -------------------------------- ### Start Conditional Expression Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/08-utilities.md Initiates a conditional expression. Use .then() and .otherwise() to define the branches. ```typescript pl.when(pl.col('a') > 5) .then(pl.lit('high')) .otherwise(pl.lit('low')) ``` -------------------------------- ### Method Chaining Example Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/04-expr.md Demonstrates fluent method chaining for Polars expressions. Multiple operations like filtering, aggregation, aliasing, and casting can be chained sequentially. ```typescript pl.col('value') .filter(pl.col('status').eq('active')) .sum() .alias('active_sum') .cast(pl.Int32) ``` -------------------------------- ### when().then().otherwise() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/08-utilities.md Starts a conditional expression. It allows defining a condition and specifying the resulting expression for both true and false outcomes. ```APIDOC ## when() ### Description Starts a conditional expression. ### Signature ```typescript when(condition: Expr): When ``` ### Returns When object with `.then()` method. ### Example ```typescript pl.when(pl.col('a') > 5) .then(pl.lit('high')) .otherwise(pl.lit('low')) ``` See [Expression API Reference](04-expr.md) for full documentation. ``` -------------------------------- ### Get First N Elements of Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Illustrates retrieving the first n elements from a Series. ```typescript head(n?: number): Series ``` -------------------------------- ### Writing DataFrame to CSV Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Shows how to write a DataFrame to a CSV file or get its CSV representation as a string. ```typescript // Write CSV df.writeCSV('output.csv'); const csv = df.writeCSV(); ``` -------------------------------- ### Create Integer Range Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/08-utilities.md Generates a range of integers. Supports custom start, end, step, and eager materialization to a Series. ```typescript pl.intRange(0, 5); pl.intRange(0, 10, 2); pl.intRange(5, 0, -1); pl.intRange(0, 5, 1, true); ``` -------------------------------- ### DataFrame Properties Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/01-dataframe.md Access properties of a DataFrame to get information about its dimensions and structure. ```APIDOC ## DataFrame Properties ### shape ```typescript shape: { height: number; width: number } ``` Returns object with `height` (row count) and `width` (column count). ### height ```typescript height: number ``` Number of rows in the DataFrame. ### width ```typescript width: number ``` Number of columns in the DataFrame. ### columns ```typescript columns: string[] get columns(): string[] set columns(cols: string[]): void ``` Get or set column names. ### dtypes ```typescript dtypes: DataType[] ``` Array of DataType for each column in column order. ``` -------------------------------- ### Get LazyDataFrame Column Names Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Retrieves an array of column names from the LazyDataFrame. ```typescript get columns(): string[] ``` -------------------------------- ### Build the debug binary Source: https://github.com/pola-rs/nodejs-polars/blob/main/CONTRIBUTING.md Compile the project in debug mode to prepare for local development and testing. ```bash yarn build:debug ``` -------------------------------- ### Get Group Indices Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/08-utilities.md The `groups` function returns the group indices for groupby operations. ```typescript df.groups(); ``` -------------------------------- ### GroupBy Aggregation: Last Value Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/06-groupby.md Get the last value of a column within each group. ```typescript pl.col('value').last(); ``` -------------------------------- ### GroupBy Aggregation: First Value Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/06-groupby.md Get the first value of a column within each group. ```typescript pl.col('value').first(); ``` -------------------------------- ### Configuring Table Display Options Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Illustrates how to configure global settings for table display, such as the number of rows, columns, and character width. ```typescript import pl from 'nodejs-polars'; pl.Config.setTblRows(5); pl.Config.setTblCols(3); pl.Config.setTblWidthChars(100); pl.Config.setAsciiTables(true); ``` -------------------------------- ### Display DataFrame as Last Expression in Deno (v1.38) Source: https://github.com/pola-rs/nodejs-polars/blob/main/README.md In Deno 1.38+, a DataFrame can be displayed by simply being the last expression in a cell. This example fetches data and reads it into a DataFrame. ```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 ``` -------------------------------- ### Run project tests Source: https://github.com/pola-rs/nodejs-polars/blob/main/CONTRIBUTING.md Execute the test suite to ensure all functionalities are working as expected. ```bash yarn test ``` -------------------------------- ### Create DataFrames and Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/INDEX.md Demonstrates creating DataFrames from objects, reading from CSV, scanning Parquet files, creating Series, and reading data from records. ```typescript // DataFrame const df = pl.DataFrame({ a: [1, 2, 3], b: ['x', 'y', 'z'] }); const df = pl.readCSV('file.csv'); const ldf = pl.scanParquet('large.parquet'); // Series const s = pl.Series('name', [1, 2, 3]); // From records const df = pl.readRecords([{ a: 1, b: 'x' }, { a: 2, b: 'y' }]); ``` -------------------------------- ### Method Chaining Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/04-expr.md Demonstrates method chaining for expressions. ```APIDOC ## Method Chaining All expression methods return an `Expr`, allowing for fluent method chaining. **Example**: ```typescript pl.col('value') .filter(pl.col('status').eq('active')) .sum() .alias('active_sum') .cast(pl.Int32) ``` ``` -------------------------------- ### clone() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Creates a cheap deep clone of the Series. ```APIDOC ## clone() ### Description Create a cheap deep clone. ### Method Signature ```typescript clone(): Series ``` ### Returns - Cloned Series. ``` -------------------------------- ### DataFrame Creation Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Demonstrates various ways to create a DataFrame, including from an object with inferred or explicit schemas, and from an array of records. ```APIDOC ## DataFrame Creation ### Description Demonstrates various ways to create a DataFrame, including from an object with inferred or explicit schemas, and from an array of records. ### Creating DataFrames ```typescript // From object with inferred schema const df = pl.DataFrame({ a: [1, 2, 3], b: ['x', 'y', 'z'] }); // With explicit schema const df = pl.DataFrame( { a: [1, 2, 3], b: ['x', 'y', 'z'] }, { schema: { a: pl.Int32, b: pl.String } } ); // From array of records const records = [{ a: 1, b: 'x' }, { a: 2, b: 'y' }]; const df = pl.readRecords(records); ``` ``` -------------------------------- ### Get Unique Values from an Expression Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/04-expr.md Remove duplicate values from an expression using the `unique` method. ```typescript unique(): Expr ``` -------------------------------- ### Get Last N Elements of Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Illustrates retrieving the last n elements from a Series. ```typescript tail(n?: number): Series ``` -------------------------------- ### Executing SQL Queries with SQLContext Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Demonstrates how to use SQLContext to execute SQL queries against DataFrames, with an option for eager execution. ```typescript const ctx = pl.SQLContext({ df1, df2 }); const result = ctx.execute('SELECT * FROM df1 WHERE x > 10', { eager: true }); ``` -------------------------------- ### Series Constructor Overloads Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Demonstrates the different ways to instantiate a Series, including providing name, values, and dtype, or using an options object. ```typescript Series( name?: string, values?: ArrayLike, dtype?: DataType ): Series Series( options: { name?: string, values: ArrayLike, dtype?: DataType } ): Series ``` -------------------------------- ### SQL Queries Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Shows how to execute SQL queries against DataFrames using the SQLContext. ```APIDOC ## SQL Queries ### Description Shows how to execute SQL queries against DataFrames using the SQLContext. ### SQL Queries ```typescript const ctx = pl.SQLContext({ df1, df2 }); const result = ctx.execute('SELECT * FROM df1 WHERE x > 10', { eager: true }); ``` ``` -------------------------------- ### sample() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Returns a random sample of elements from the Series with various options for sampling. ```APIDOC ## sample() ### Description Random sample of elements. ### Method Signature ```typescript sample(options?: { n?: number, fraction?: number, withReplacement?: boolean, seed?: number }): Series ``` ### Parameters #### Path Parameters - **n** (number) - Optional - Number of elements to sample. - **fraction** (number) - Optional - Fraction to sample (0-1). - **withReplacement** (boolean) - Optional - Sample with replacement; default false. - **seed** (number) - Optional - Random seed. ### Returns - Sampled Series. ``` -------------------------------- ### List Operations Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Perform operations on List Series, such as getting lengths, accessing elements by index, joining, and exploding. ```APIDOC ### List Operations (list) Available on List Series: ```typescript s.list.lengths(); s.list.getByIndex(index); s.list.join(separator); s.list.explode(); ``` ``` -------------------------------- ### Create Empty SQLContext Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/07-sql.md Initialize an empty SQLContext without any pre-registered tables. ```typescript import pl from 'nodejs-polars'; // Empty context const ctx = pl.SQLContext(); ``` -------------------------------- ### argSortBy() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/08-utilities.md Get the indices that would sort the data by the specified expressions. This is useful for understanding the order of elements after sorting. ```APIDOC ## argSortBy() ### Description Get indices that would sort by expressions. ### Method (Not specified, likely a method on a DataFrame or Expression object) ### Parameters - **...exprs** (Expr[]) - Expressions to sort by. ### Request Example ```typescript df.select(pl.argSortBy('col1', 'col2')); ``` ### Response - **Expr** - Returns an expression object representing the sorting indices. ``` -------------------------------- ### Get Sorting Indices Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/08-utilities.md Use `argSortBy` to obtain the indices that would sort the DataFrame based on one or more columns. ```typescript df.select(pl.argSortBy('col1', 'col2')); ``` -------------------------------- ### describe() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Computes and returns summary statistics for the Series, including min, max, mean, standard deviation, and count. ```APIDOC ## describe() ### Description Compute summary statistics. ### Method Not applicable (Instance method) ### Returns - **DataFrame** - A DataFrame containing statistics (min, max, mean, std, count, etc.). ``` -------------------------------- ### Series Properties Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Access properties of a Series to get its name, data type, length, or specialized function namespaces. ```APIDOC ## Series Properties ### name - **Type**: `string` - **Description**: The name of the Series. ### dtype - **Type**: `DataType` - **Description**: The data type of all values in the Series. ### length - **Type**: `number` - **Description**: Number of elements in the Series. ### str - **Type**: `SeriesStringFunctions` - **Description**: String operations namespace. Only valid for String type Series. ### dt - **Type**: `SeriesDateFunctions` - **Description**: Datetime operations namespace. Valid for Date, Time, Datetime, Duration types. ### list - **Type**: `SeriesListFunctions` - **Description**: List operations namespace. Only valid for List type Series. ### struct - **Type**: `SeriesStructFunctions` - **Description**: Struct operations namespace. Only valid for Struct type Series. ``` -------------------------------- ### describePlan() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Retrieves the unoptimized query plan of the LazyDataFrame as a string. ```APIDOC ## describePlan() ### Description Get unoptimized query plan as string. ### Method `describePlan(): string` ### Response #### Success Response - **string** - String representation of logical plan. ### Request Example ```typescript const plan = ldf.describePlan(); ``` ``` -------------------------------- ### Join LazyDataFrame on Same Column Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Example of joining two LazyDataFrames on a column with the same name. Uses the 'on' option for simplicity. ```typescript ldf1.join(ldf2, { on: 'id' }); ``` -------------------------------- ### Run precommit checks Source: https://github.com/pola-rs/nodejs-polars/blob/main/CONTRIBUTING.md Ensure all tests pass and code is formatted correctly before committing changes. ```bash yarn precommit ``` -------------------------------- ### Importing Data Types and Creating DataFrame Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Demonstrates how to import the Polars namespace and use data types for schema definition when creating a DataFrame. ```typescript import pl from 'nodejs-polars'; const dt = pl.Int64; const df = pl.DataFrame({ a: [1, 2, 3] }, { schema: { a: pl.Int64 } }); ``` -------------------------------- ### Multiple Grouping Columns Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/06-groupby.md Demonstrates grouping by multiple columns using either string arguments or an array of strings. ```APIDOC ## Multiple Grouping Columns ### Description Group by unique combinations of multiple columns. ### Examples ```typescript // Using multiple string arguments df.groupBy('col1', 'col2').agg(pl.col('value').sum()); // Using an array of strings df.groupBy(['col1', 'col2']).agg(pl.col('value').sum()); ``` ``` -------------------------------- ### head() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Returns the first n elements of the Series. ```APIDOC ## head() ### Description Return first n elements (default 5). ### Method Signature ```typescript head(n?: number): Series ``` ``` -------------------------------- ### Get Column as Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/01-dataframe.md Retrieve a specific column from the DataFrame as a Series object. This can also be done using bracket notation. ```typescript const s = df.getColumn('a'); ``` ```typescript const s = df['a']; ``` -------------------------------- ### Get Indices of Unique Values Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Returns a Series containing the indices of the first occurrence of each unique value in the original Series. ```typescript argUnique(): Series ``` -------------------------------- ### Configuration Settings Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Demonstrates how to configure Polars display options such as table rows, columns, and character width. ```APIDOC ## Configuration Settings ### Description Demonstrates how to configure Polars display options such as table rows, columns, and character width. ### Configuration ```typescript import pl from 'nodejs-polars'; pl.Config.setTblRows(5); pl.Config.setTblCols(3); pl.Config.setTblWidthChars(100); pl.Config.setAsciiTables(true); ``` ``` -------------------------------- ### Get Indices of True Values in Boolean Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md For a boolean Series, returns a Series containing the indices where the values are true. ```typescript argTrue(): Series ``` -------------------------------- ### Importing Node.js Polars Source: https://github.com/pola-rs/nodejs-polars/blob/main/README.md Demonstrates how to import the nodejs-polars library using both ES Module (esm) and CommonJS (require) syntax. ```javascript // esm import pl from 'nodejs-polars'; // require const pl = require('nodejs-polars'); ``` -------------------------------- ### Create SQLContext with Pre-registered Tables Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/07-sql.md Initialize a SQLContext with DataFrames or LazyDataFrames already registered as tables. ```typescript import pl from 'nodejs-polars'; // Pre-register tables const df1 = pl.DataFrame({ a: [1, 2], b: [3, 4] }); const df2 = pl.DataFrame({ c: [5, 6], d: [7, 8] }); const ctx = pl.SQLContext({ table1: df1, table2: df2 }); ``` -------------------------------- ### groups() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/08-utilities.md Get group indices for groupby operations. This function is used in conjunction with groupby operations to identify the indices belonging to each group. ```APIDOC ## groups() ### Description Get group indices for groupby operations. ### Method (Not specified, likely a method on a DataFrame or Expression object) ### Response - **Expr** - Returns an expression object representing the group indices. ``` -------------------------------- ### Clone Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Illustrates creating a cheap deep clone of a Series. ```typescript clone(): Series ``` -------------------------------- ### Correcting List Operation Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/errors.md Shows how to perform list-specific operations before aggregation, such as getting the lengths of lists within a column, to avoid InvalidOperationError. ```typescript // ❌ Wrong const result = listCol.mean(); // ✅ Correct const result = listCol.list.lengths().mean(); ``` -------------------------------- ### WriteAvroOptions Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/types.md Avro output options, specifying the compression codec to be used. ```APIDOC ## WriteAvroOptions ### Description Avro output options. ### Fields - **compression** (string) - Optional - Compression codec. Supported values: 'uncompressed', 'snappy', 'deflate'. ``` -------------------------------- ### Aggregate LazyDataFrame after GroupBy Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Perform aggregation operations on a grouped LazyDataFrame. Examples show summing a column and calculating the mean of another. ```typescript ldf.groupBy('group').agg([pl.col('value').sum()]); ldf.groupBy('a', 'b').agg(pl.col('c').mean()); ``` -------------------------------- ### Describe Unoptimized Query Plan Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Retrieve the unoptimized logical query plan as a string. ```typescript ldf.describePlan(); ``` -------------------------------- ### List Operations Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/04-expr.md Provides methods for manipulating list-type expressions, such as getting lengths, accessing elements, exploding, concatenating, slicing, and performing aggregations. ```typescript expr.list.lengths(); expr.list.getByIndex(index); expr.list.getByIndexExpr(index); expr.list.first(); expr.list.last(); expr.list.explode(); expr.list.concat(other); expr.list.join(separator); expr.list.slice(offset, length); expr.list.head(n); expr.list.tail(n); expr.list.contains(item); expr.list.unique(); expr.list.max(); expr.list.min(); expr.list.sum(); expr.list.mean(); expr.list.reverse(); expr.list.sort(); ``` -------------------------------- ### Get the last value expression Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/04-expr.md Use the `last()` aggregation function to retrieve the last value in a column or group. This is often used after sorting. ```typescript pl.last(); ``` -------------------------------- ### Describe Optimized Query Plan Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Retrieve the optimized logical query plan as a string, with optional optimization configurations. ```typescript ldf.describeOptimizedPlan(opts); ``` -------------------------------- ### Efficient GroupBy with Projection Pushdown Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/06-groupby.md Demonstrates an efficient way to perform groupBy by selecting only necessary columns before the operation, leveraging projection pushdown. ```typescript // ✅ More efficient df.select(['group', 'value']) .groupBy('group') .agg(pl.col('value').sum()); ``` -------------------------------- ### Get the first value expression Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/04-expr.md Use the `first()` aggregation function to retrieve the first value in a column or group. This is often used after sorting. ```typescript pl.first(); ``` -------------------------------- ### Get Unique Rows from LazyDataFrame Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Remove duplicate rows from a LazyDataFrame. You can specify a subset of columns to consider for uniqueness and control which duplicate to keep. ```typescript unique(options?: { subset?: string[], keep?: 'first' | 'last' | 'none', maintainOrder?: boolean }): LazyDataFrame ``` -------------------------------- ### Version Information Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Demonstrates how to access the version of the nodejs-polars library. ```APIDOC ## Version ### Description Access the library version. ### Version ```typescript import pl from 'nodejs-polars'; console.log(pl.version); ``` ``` -------------------------------- ### Struct Operations Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/04-expr.md Methods for interacting with struct-type expressions, including retrieving field names, getting specific fields by name, and unnesting struct fields. ```typescript expr.struct.fieldNames(); expr.struct.getFieldByName(field); expr.struct.getAllFields(); expr.struct.unnest(); ``` -------------------------------- ### Create SQLContext with Mixed Eager and Lazy Frames Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/07-sql.md Initialize a SQLContext with a mix of eager DataFrames and lazy LazyDataFrames. ```typescript import pl from 'nodejs-polars'; // Mix eager and lazy const ldf = pl.scanCSV('large.csv'); const ctx = pl.SQLContext({ eager_table: df1, lazy_table: ldf }); ``` -------------------------------- ### Get Last N Rows Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/01-dataframe.md Use `tail()` to retrieve the last `n` rows of a DataFrame. Defaults to the last 5 rows if `n` is not specified. ```typescript df.tail(10); ``` -------------------------------- ### Chain Configuration Settings Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/configuration.md All configuration methods are chainable, allowing for fluent API usage to set multiple display options in a single statement. ```typescript import pl from 'nodejs-polars'; pl.Config .setAsciiTables(true) .setTblRows(10) .setTblCols(5) .setThousandsSeparator(true); ``` -------------------------------- ### Get First N Rows Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/01-dataframe.md Use `head()` to retrieve the first `n` rows of a DataFrame. Defaults to the first 5 rows if `n` is not specified. ```typescript df.head(10); ``` -------------------------------- ### WriteIPCOptions Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/types.md Arrow IPC output options, allowing selection of the compression codec. ```APIDOC ## WriteIPCOptions ### Description Arrow IPC output options. ### Fields - **compression** (string) - Optional - Compression codec. Supported values: 'uncompressed', 'lz4', 'zstd'. ``` -------------------------------- ### Get First N Rows of LazyDataFrame Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Retrieve the first 'n' rows from a LazyDataFrame. Defaults to 5 rows if 'n' is not specified. Useful for previewing data. ```typescript head(n?: number): LazyDataFrame ``` -------------------------------- ### Configure Polars Display and Behavior Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/INDEX.md Demonstrates how to configure Polars settings such as the number of rows displayed, table formatting, and ASCII table output. ```typescript pl.Config .setTblRows(10) .setAsciiTables(true) .setTblWidthChars(100); ``` -------------------------------- ### SQLContext Constructor Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/07-sql.md Creates a SQL context, which allows executing SQL queries against registered DataFrames or LazyDataFrames. You can optionally pre-register tables during initialization. ```APIDOC ## SQLContext Constructor ```typescript SQLContext(frames?: Record): SQLContext ``` ### Description Create a SQL context with optional initial DataFrames/LazyFrames. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **frames** (Record) - Optional - Initial tables to register ### Request Example ```typescript import pl from 'nodejs-polars'; // Empty context const ctx = pl.SQLContext(); // Pre-register tables const df1 = pl.DataFrame({ a: [1, 2], b: [3, 4] }); const df2 = pl.DataFrame({ c: [5, 6], d: [7, 8] }); const ctx = pl.SQLContext({ table1: df1, table2: df2 }); // Mix eager and lazy const ldf = pl.scanCSV('large.csv'); const ctx = pl.SQLContext({ eager_table: df1, lazy_table: ldf }); ``` ### Response #### Success Response (200) * **SQLContext instance** #### Response Example None ``` -------------------------------- ### Struct Operations on Struct Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Access and manipulate Struct Series, including retrieving field names, getting fields by name, retrieving all fields, and unnesting the struct. ```typescript s.struct.fieldNames(); s.struct.getFieldByName(field); s.struct.getAllFields(); s.struct.unnest(); ``` -------------------------------- ### Sample Series Elements Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Demonstrates how to randomly sample elements from a Series with options for count, fraction, replacement, and seed. ```typescript sample(options?: { n?: number, fraction?: number, withReplacement?: boolean, seed?: number }): Series ``` -------------------------------- ### List Operations on List Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Manipulate List Series by getting lengths, retrieving elements by index, joining elements with a separator, or exploding the list into separate rows. ```typescript s.list.lengths(); s.list.getByIndex(index); s.list.join(separator); s.list.explode(); ``` -------------------------------- ### format() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/08-utilities.md Formats a string using expressions as arguments, similar to Python's string formatting. Allows embedding dynamic values into strings. ```APIDOC ## format() ### Description Format string with expressions using format string syntax. ### Signature ```typescript format(fmt: string, ...args: Expr[]): Expr ``` ### Example ```typescript pl.format('Value: {}', pl.col('value')); pl.format('{} - {}, Age: {}', pl.col('first'), pl.col('last'), pl.col('age')); ``` ``` -------------------------------- ### setVerbose Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/configuration.md Enable verbose or debug logging output. This method is chainable. ```APIDOC ## setVerbose ### Description Enable verbose/debug logging output. ### Method Config.setVerbose(active?: boolean): Config ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **active** (boolean) - Optional - Enable verbose logging. Defaults to false. ### Returns Config ``` -------------------------------- ### String Operations on Utf8 Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Perform string manipulations on Utf8 Series, including getting lengths, converting case, checking for patterns, splitting, and replacing substrings. ```typescript s.str.lengths(); s.str.toUppercase(); s.str.toLowercase(); s.str.contains(pattern); s.str.split(by); s.str.replace(pattern, value); ``` -------------------------------- ### Get Indices for Sorting Series Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Returns a Series containing the indices that would sort the original Series. Options allow for descending order and placing nulls last. ```typescript argSort(options?: { descending?: boolean, nullsLast?: boolean }): Series ``` ```typescript argSort(descending?: boolean): Series ``` -------------------------------- ### Import Polars in Deno Source: https://github.com/pola-rs/nodejs-polars/blob/main/README.md Import the nodejs-polars library in Deno using npm. ```typescript import pl from "npm:nodejs-polars"; ``` -------------------------------- ### Get Unique Series Elements Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Returns a new Series containing only the unique elements from the original Series. Duplicates can be optionally removed by keeping the first or last occurrence. ```typescript unique(options?: { keep?: 'first' | 'last' }): Series ``` -------------------------------- ### Display DataFrame in Deno Notebook (v1.37) Source: https://github.com/pola-rs/nodejs-polars/blob/main/README.md Use the display function to show a DataFrame in a Deno notebook. Requires fetching data and reading it into a DataFrame. ```typescript import pl from "npm:nodejs-polars"; import { display } from "https://deno.land/x/display@v1.1.2/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) ``` -------------------------------- ### Get Last N Rows of LazyDataFrame Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Retrieve the last 'n' rows from a LazyDataFrame. Defaults to 5 rows if 'n' is not specified. Useful for examining the tail end of data. ```typescript tail(n?: number): LazyDataFrame ``` -------------------------------- ### head() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/08-utilities.md Returns an expression that selects the first n values. ```APIDOC ## head() ### Description Return first n values. ### Method Signature ```typescript head(n?: number): Expr ``` ``` -------------------------------- ### Join LazyDataFrame on Different Columns with Join Type Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Example of joining two LazyDataFrames on columns with different names, specifying a 'left' join type. Uses 'leftOn' and 'rightOn' options. ```typescript ldf1.join(ldf2, { leftOn: 'id1', rightOn: 'id2', how: 'left' }); ``` -------------------------------- ### head() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/03-lazydataframe.md Returns the first n rows of a LazyDataFrame. Defaults to the first 5 rows. ```APIDOC ## head() ### Description Returns the first n rows of a LazyDataFrame. Defaults to the first 5 rows. ### Method Signature ```typescript head(n?: number): LazyDataFrame ``` ### Parameters - **n** (number) - Optional - Number of rows to return; default 5 ### Returns LazyDataFrame with the first n rows. ``` -------------------------------- ### Compile Polars from Source (Fastest Binary) Source: https://github.com/pola-rs/nodejs-polars/blob/main/README.md Compile the Polars library from source for the fastest binary, which may result in long compile times. This command builds the TypeScript code and the Rust binary. ```bash cd nodejs-polars && yarn build && yarn build:ts ``` -------------------------------- ### Creating DataFrame with Explicit Schema Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Illustrates creating a DataFrame by explicitly defining the schema for each column. ```typescript // With explicit schema const df = pl.DataFrame( { a: [1, 2, 3], b: ['x', 'y', 'z'] }, { schema: { a: pl.Int32, b: pl.String } } ); ``` -------------------------------- ### Writing DataFrame to Parquet Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Demonstrates writing a DataFrame to a Parquet file. ```typescript // Write Parquet df.writeParquet('output.parquet'); ``` -------------------------------- ### Grouping and Aggregation Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/00-overview.md Shows how to perform group-by operations and aggregations on DataFrames, both eagerly and lazily. ```APIDOC ## Grouping and Aggregation ### Description Shows how to perform group-by operations and aggregations on DataFrames, both eagerly and lazily. ### Grouping and Aggregation ```typescript // Eager groupby df.groupBy('group_col').agg(pl.col('value').sum(), pl.col('value').mean()); // Lazy groupby df.lazy() .groupBy('group_col') .agg([pl.col('value').sum(), pl.col('value').mean()]) .collect(); ``` ``` -------------------------------- ### JoinOptions Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/types.md Configuration for join operations, allowing specification of join keys, strategy, and handling of duplicate columns. ```APIDOC ## JoinOptions ### Description Configuration for join operations. This type can be one of `SameNameColumnJoinOptions`, `DifferentNameColumnJoinOptions`, or `CrossJoinOptions`. ### Fields #### `SameNameColumnJoinOptions` - **on** (string | string[]) - Required - Join key column(s). - **how** (JoinType) - Optional - Join strategy; default 'inner'. - **suffix** (string) - Optional - Suffix for duplicate columns; default '_right'. - **coalesce** (boolean) - Optional - Merge join columns; default true. - **validate** (string) - Optional - Validation mode (advanced). #### `DifferentNameColumnJoinOptions` - **leftOn** (string | string[]) - Required - Join key column(s) on the left DataFrame. - **rightOn** (string | string[]) - Required - Join key column(s) on the right DataFrame. - **how** (JoinType) - Optional - Join strategy; default 'inner'. - **suffix** (string) - Optional - Suffix for duplicate columns; default '_right'. - **coalesce** (boolean) - Optional - Merge join columns; default true. - **validate** (string) - Optional - Validation mode (advanced). #### `CrossJoinOptions` - **how** ('cross') - Required - Must be 'cross' for a cross join. - **suffix** (string) - Optional - Suffix for duplicate columns; default '_right'. - **coalesce** (boolean) - Optional - Merge join columns; default true. - **validate** (string) - Optional - Validation mode (advanced). **JoinType**: 'left' | 'inner' | 'full' | 'semi' | 'anti' | 'cross' ``` -------------------------------- ### Execute SQL Query Eagerly Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/07-sql.md Execute a SQL query and immediately return the results as a DataFrame. Use this when you need the data right away. ```typescript const ctx = pl.SQLContext({ films: df }); // Execute eagerly (immediate result) const result = ctx.execute('SELECT * FROM films WHERE year > 1990', { eager: true }); ``` -------------------------------- ### ReadParquetOptions Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/types.md Configuration options for reading Parquet files. Allows specifying columns, number of rows, parallelization strategy, and adding a row count column. ```APIDOC ## ReadParquetOptions ### Description Options for reading Parquet files. You can select specific columns, limit the number of rows, define the parallelization strategy, and optionally add a row count column. ### Fields - **columns** (string[] | number[]) - Optional - Columns to read. - **numRows** (number) - Optional - Maximum number of rows to read. - **parallel** (string) - Optional - Parallelization strategy ('auto', 'columns', 'row_groups', 'none'). Defaults to 'auto'. - **rowCount** (RowCount) - Optional - Configuration to add a row count column. ``` -------------------------------- ### groupBy() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/01-dataframe.md Initiate a groupby operation for subsequent aggregation. Can group by multiple columns. ```APIDOC ## groupBy() ### Description Start a groupby operation for aggregation. ### Method ```typescript groupBy(...columns: (string | Expr)[]): GroupBy groupBy(columns: (string | Expr)[]): GroupBy ``` ### Parameters #### Path Parameters - **columns** ((string | Expr)[]) - Required - Column names to group by ### Response #### Success Response (200) - **GroupBy** - GroupBy object with `.agg()` method. ### Request Example ```typescript df.groupBy('group').agg(pl.col('value').sum()); df.groupBy('a', 'b').agg([pl.col('c').mean(), pl.col('d').max()]); ``` ``` -------------------------------- ### head() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/01-dataframe.md Retrieve the first 'n' rows of the DataFrame. ```APIDOC ## head() ### Description Return first n rows (default 5). ### Method ```typescript head(n?: number): DataFrame ``` ### Parameters #### Path Parameters - **n** (number) - Optional - Number of rows to retrieve; default 5. ``` -------------------------------- ### describe() Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/01-dataframe.md Compute and return summary statistics for numeric columns in the DataFrame. ```APIDOC ## describe() ### Description Compute summary statistics (mean, std, min, max, median) for numeric columns. ### Method ```typescript describe(): DataFrame ``` ### Response #### Success Response (200) - **DataFrame** - DataFrame with statistics. ``` -------------------------------- ### Utility Methods Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/04-expr.md General utility methods for expressions. ```APIDOC ## Utility Methods ### abs(): Expr Calculates the absolute value of the expression. **Returns**: Expr. ### sign(): Expr Returns the sign of the value (-1, 0, or 1). ### sqrt(): Expr Calculates the square root of the expression. ### pow(exponent: number | Expr): Expr Raises the expression to the power of the given exponent. ### log(base?: number): Expr Calculates the logarithm of the expression. | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | base | number | No | Logarithm base; default e | ### log10(): Expr Calculates the base-10 logarithm of the expression. ### exp(): Expr Calculates the exponential of the expression (e^x). ### sin(): Expr Calculates the sine of the expression. ### cos(): Expr Calculates the cosine of the expression. ### tan(): Expr Calculates the tangent of the expression. ``` -------------------------------- ### Convert Series to Array Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/api-reference/02-series.md Shows how to convert a Series into a standard JavaScript array. ```typescript const arr = s.toArray(); // [1, 2, 3] ``` -------------------------------- ### ScanParquetOptions Source: https://github.com/pola-rs/nodejs-polars/blob/main/_autodocs/types.md Options for lazily scanning Parquet files. Includes settings for row limits, indexing, caching, parallelization, partitioning, and cloud storage. ```APIDOC ## ScanParquetOptions ### Description Options for lazily scanning Parquet files. This allows for efficient reading of large datasets by deferring computation. You can control row limits, caching, parallelization, and Hive partitioning. ### Fields - **nRows** (number) - Optional - Maximum number of rows to scan. - **rowIndexName** (string) - Optional - Name for the row index column. - **rowIndexOffset** (number) - Optional - Offset for the row index. - **cache** (boolean) - Optional - Whether to cache the scanned data. - **parallel** (string) - Optional - Parallelization strategy ('auto', 'columns', 'row_groups', 'none'). - **glob** (boolean) - Optional - Whether to use glob patterns for file paths. - **hivePartitioning** (boolean) - Optional - Whether to enable Hive partitioning. - **hiveSchema** (unknown) - Optional - Schema for Hive partitioning. - **tryParseHiveDates** (boolean) - Optional - Whether to try parsing Hive dates. - **rechunk** (boolean) - Optional - Whether to rechunk the data. - **lowMemory** (boolean) - Optional - Whether to use low memory mode. - **useStatistics** (boolean) - Optional - Whether to use statistics for optimization. - **cloudOptions** (Record) - Optional - Cloud storage options. - **retries** (number) - Optional - Number of retries for cloud operations. - **includeFilePaths** (string) - Optional - Path to include files. - **allowMissingColumns** (boolean) - Optional - Whether to allow missing columns. ```