### padstart Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Pads the start of a string with a specified fill string to reach a target length. ```APIDOC ## padstart ### Description Pad a string *value* with a given *fill* string (applied from the start of *value* and repeated, if needed) so that the resulting string reaches a given *length*. ### Parameters * *value*: The input string to pad. * *length*: The length of the resulting string once the *value* string has been padded. If the length is lower than `value.length`, the *value* string will be returned as-is. * *fill*: The string to pad the *value* string with (default `''`). If *fill* is too long to stay within the target *length*, it will be truncated: for left-to-right languages the left-most part and for right-to-left languages the right-most will be applied. ``` -------------------------------- ### startswith Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Checks if a string starts with a specified search string. ```APIDOC ## startswith ### Description Determines whether a string *value* starts with the characters of a specified *search* string, returning `true` or `false` as appropriate. ### Parameters * *value*: The input string value. * *search*: The search string to test for. * *position*: The position in the *value* string at which to begin searching (default `0`). ``` -------------------------------- ### Parse CSV from Compressed Stream Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Parses CSV data from a compressed input stream. This example demonstrates stream decompression and decoding before passing to Arquero. ```javascript // parse CSV from a compressed input stream // (these stream transforms are performed internally by loadCSV) const stream = (await fetch(url).then(res => res.body)) .pipeThrough(new DecompressionStream('gzip')) // decompress bytes .pipeThrough(new TextDecoderStream()); // map bytes to strings await aq.fromCSVStream(stream); ``` -------------------------------- ### op.slice Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Returns a copy of a portion of the sequence selected from start to end. ```APIDOC ## op.slice ### Description Returns a copy of a portion of the input sequence (array or string) selected from start to end (end not included) where start and end represent the index of items in the sequence. ### Parameters #### Path Parameters - **sequence** (any[] | string) - Required - The input array or string value. - **start** (number) - Optional - The starting index of the slice. - **end** (number) - Optional - The ending index of the slice (not included). ### Response #### Success Response (200) - **array | string** - A new array or string containing the sliced portion. ### Response Example ```json { "example": "[ 'b', 'c' ]" } ``` ``` -------------------------------- ### op.sequence Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Returns an array containing an arithmetic sequence from start to stop, in step increments. ```APIDOC ## op.sequence ### Description Returns an array containing an arithmetic sequence from the start value to the stop value, in step increments. If step is positive, the last element is the largest start + i * step less than stop; if step is negative, the last element is the smallest start + i * step greater than stop. If the returned array would contain an infinite number of values, an empty range is returned. ### Parameters #### Path Parameters - **start** (number) - Optional - The starting value of the sequence (default `0`). - **stop** (number) - Required - The stopping value of the sequence. The stop value is exclusive; it is not included in the result. - **step** (number) - Optional - The step increment between sequence values (default `1`). ### Response #### Success Response (200) - **array** (number[]) - An array containing the arithmetic sequence. ### Response Example ```json { "example": "[ 0, 1, 2, 3, 4 ]" } ``` ``` -------------------------------- ### op.rank() Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Window function to assign a rank to each value in a group, starting from 1. Peer values receive the same rank, and subsequent ranks account for ties. ```APIDOC ## op.rank() ### Description Window function to assign a rank to each value in a group, starting from 1. Peer values are assigned the same rank. Subsequent ranks reflect the number of prior values: if the first two values tie for rank 1, the third value is assigned rank 3. ### Method N/A (Function call) ### Parameters None ### Request Example ``` op.rank() ``` ### Response N/A (Returns a table expression) ``` -------------------------------- ### op.avg_rank() Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Window function to assign a fractional (average) rank to each value in a group, starting from 1. Peer values are assigned the average of their indices. ```APIDOC ## op.avg_rank() ### Description Window function to assign a fractional (average) rank to each value in a group, starting from 1. Peer values are assigned the average of their indices: if the first two values tie, both will be assigned rank 1.5. ### Method N/A (Function call) ### Parameters None ### Request Example ``` op.avg_rank() ``` ### Response N/A (Returns a table expression) ``` -------------------------------- ### Get Column Instance by Index Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieve a column instance by its zero-based index. Similar to 'column(name)', the returned object abstracts column storage and offers a 'get(row)' method. ```javascript const dt = aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) dt.columnAt(1).get(1) // 5 ``` -------------------------------- ### Get Column Instance by Name Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieve a column instance by its name. The column object provides access to column storage and methods like 'get(row)'. It does not track table filters or order. ```javascript const dt = aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) dt.column('b').get(1) // 5 ``` -------------------------------- ### Registering a Custom Window Function Source: https://github.com/uwdata/arquero/blob/main/docs/api/extensibility.md Demonstrates how to register a new window function using `aq.addWindowFunction`. This function can then be used with the `op` object for data transformations. ```APIDOC ## aq.addWindowFunction(name, def, options) ### Description Registers a custom window function that can be accessed via the `op` object. ### Parameters * **name**: (string) The name to use for the window function. * **def**: (object) A window operator definition object. * **create**: (function) A creation function that returns a window operator instance with `init` and `value` methods. * **param**: (array) Two-element array containing the counts of input fields and additional parameters. * **options**: (object, optional) Function registration options. * **override**: (boolean, default `false`) If `true`, allows overriding an existing function with the same name. ### Examples ```js // add a window function that outputs the minimum of a field value // and the current sorted window index, plus an optional offset aq.addWindowFunction('idxmin', { create: (offset = 0) => ({ init: () => {}, value: (w, f) => Math.min(w.value(w.index, f), w.index) + offset }), param: [1, 1] // 1 field input, 1 extra parameter }); table({ x: [4, 3, 2, 1] }) .derive({ x: op.idxmin('x', 1) }) // { x: [1, 2, 3, 2] } ``` ``` -------------------------------- ### Derive, Select, Orderby, and Print Data Source: https://github.com/uwdata/arquero/blob/main/README.md Demonstrates deriving new columns, selecting specific columns, ordering by a derived column in descending order, and printing the result. Requires importing 'all', 'desc', 'op', and 'table' from 'arquero'. ```javascript import { all, desc, op, table } from 'arquero'; // Average hours of sunshine per month, from https://usclimatedata.com/. const dt = table({ 'Seattle': [69,108,178,207,253,268,312,281,221,142,72,52], 'Chicago': [135,136,187,215,281,311,318,283,226,193,113,106], 'San Francisco': [165,182,251,281,314,330,300,272,267,243,189,156] }); // Sorted differences between Seattle and Chicago. // Table expressions use arrow function syntax. dt.derive({ month: d => op.row_number(), diff: d => d.Seattle - d.Chicago }) .select('month', 'diff') .orderby(desc('diff')) .print(); ``` -------------------------------- ### Create Table with Columns Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Creates a new table with specified columns and optionally explicit column names. Use the 'names' argument to ensure proper column ordering, especially when integer keys are present. ```javascript aq.table({ colA: ['a', 'b', 'c'], colB: [3, 4, 5] }) ``` ```javascript aq.table({ key: ['a', 'b'], 1: [9, 8], 2: [7, 6] }, ['key', '1', '2']) ``` ```javascript const map = new Map() .set('colA', ['a', 'b', 'c']) .set('colB', [3, 4, 5]); aq.table(map) ``` -------------------------------- ### op.row_number() Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Window function to assign consecutive row numbers, starting from 1. ```APIDOC ## op.row_number() ### Description Window function to assign consecutive row numbers, starting from 1. ### Method N/A (Function call) ### Parameters None ### Request Example ``` op.row_number() ``` ### Response N/A (Returns a table expression) ``` -------------------------------- ### Select Columns by Prefix Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Use `aq.startswith()` to select columns whose names begin with a specified string. This is helpful for selecting columns that share a common prefix. ```javascript aq.startswith('prefix_') ``` -------------------------------- ### Aggregate and Window Shorthands Source: https://github.com/uwdata/arquero/blob/main/docs/api/expressions.md Illustrates shorthand references for aggregate and window functions using the op object outside of a table expression. ```javascript d => op.mean(d.value) ``` ```javascript op.mean('value') ``` -------------------------------- ### Get Number of Columns - Arquero Table Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieves the total number of columns in the table. This is a simple property access. ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .numCols() // 2 ``` -------------------------------- ### Create Table from Fetched JSON String Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Load JSON data from a URL by first fetching the response as text and then passing it to `aq.fromJSON`. ```javascript aq.fromJSON(await fetch(url).then(res => res.text())) ``` -------------------------------- ### aq.startswith(string) Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Selects columns whose names begin with a specified string. Compatible with select, groupby, and join verbs. ```APIDOC ## aq.startswith(string) ### Description Selects columns whose names begin with a specified string. Compatible with select, groupby, and join verbs. ### Parameters #### Arguments - **string**: The string that column names must start with. ### Method ```javascript aq.startswith('prefix_') ``` ``` -------------------------------- ### Get Column Name by Index Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieve the name of a column at a specified zero-based index. Returns undefined if the index is out of range. ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .columnName(1); // 'b' ``` -------------------------------- ### aq.range(start, stop) Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Selects a contiguous range of columns by name or index. Compatible with select, groupby, and join verbs. ```APIDOC ## aq.range(start, stop) ### Description Selects a contiguous range of columns by name or index. Compatible with select, groupby, and join verbs. ### Parameters #### Arguments - **start**: The name or integer index of the first column in the range. - **stop**: The name or integer index of the last column in the range. ### Method ```javascript aq.range('colB', 'colE') aq.range(2, 5) ``` ``` -------------------------------- ### Load Arquero and Apache Arrow from CDN in Browser Source: https://github.com/uwdata/arquero/blob/main/README.md To use Arrow encoding or binary file loading, load both Apache Arrow and Arquero from CDNs. Ensure Arrow is loaded before Arquero. ```html ``` -------------------------------- ### Get Row Indices Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Returns an array of indices for all rows that satisfy the current table filter. The indices can be sorted if the table is ordered. ```javascript table.indices() ``` ```javascript table.indices(false) ``` -------------------------------- ### Load Arquero in Browser via CDN Source: https://github.com/uwdata/arquero/blob/main/docs/index.md This HTML snippet shows how to include Arquero in a web page using a Content Delivery Network (CDN). Arquero will be available globally as the `aq` object. ```html ``` -------------------------------- ### Get All Column Names Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Obtain an array of all column names in the table. An optional filter callback can be provided to selectively return names. ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .columnNames(); // [ 'a', 'b' ] ``` -------------------------------- ### aq.fromArrow Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Creates a new table backed by Apache Arrow binary data. Supports various Arrow input types and provides options for data import. ```APIDOC ## aq.fromArrow(input[, options]) ### Description Returns a new table backed by Apache Arrow binary data. The input can be a byte array in the Arrow IPC format, or an instantiated Flechette or Apache Arrow JS table instance. Binary inputs are decoded using Flechette. For many data types, Arquero uses binary-encoded Arrow columns as-is with zero data copying. For dictionary columns, Arquero unpacks columns with null entries or containing multiple record batches to optimize query performance. Both the Arrow IPC `stream` and `file` formats are supported; the format type is determined automatically. This method performs parsing only. To specify a URL or file to load, use [loadArrow](#loadArrow). ### Parameters * `input` (byte array or Arrow table instance): A byte array (e.g., ArrayBuffer or Uint8Array) in the Arrow IPC format, or a Flechette or Apache Arrow JS table instance. * `options` (object, optional): An Arrow import options object. * `columns` (Select): An ordered set of columns to import. Can be column name strings, column integer indices, objects with current column names as keys and new column names as values, or selection helper functions like `all`, `not`, or `range`. * `useBigInt` (boolean, optional, default `false`): Extracts 64-bit integer types as JavaScript `BigInt`. For Flechette tables, the default is to coerce 64-bit integers to JavaScript numbers and raise an error if the number is out of range. This option is only applied when parsing IPC binary data. * `useDate` (boolean, optional, default `true`): Converts Arrow date and timestamp values to JavaScript Date objects. Otherwise, numeric timestamps are used. This option is only applied when parsing IPC binary data. * `useDecimalBigInt` (boolean, optional, default `false`): Extracts Arrow decimal-type data as BigInt values. Otherwise, decimals are converted to floating-point numbers. This option is only applied when parsing IPC binary data. * `useMap` (boolean, optional, default `false`): Represents Arrow Map data as JavaScript `Map` values. For Flechette tables, the default is to produce an array of `[key, value]` arrays. This option is only applied when parsing IPC binary data. * `useProxy` (boolean, optional, default `false`): Extracts Arrow Struct values and table row objects using zero-copy proxy objects. This option is only applied when parsing IPC binary data. ### Request Example ```js // encode input table as Arrow IPC bytes const arrowBytes = aq.table({ x: [1, 2, 3, 4, 5], y: [3.4, 1.6, 5.4, 7.1, 2.9] }) .toArrowIPC(); // access the Arrow-encoded data as an Arquero table const dt = aq.fromArrow(arrowBytes); ``` ``` -------------------------------- ### Get Column Index by Name Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Find the zero-based index of a column given its name. Returns -1 if the column name is not found. ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .columnIndex('b'); // 1 ``` -------------------------------- ### Select All Columns Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Use `aq.all()` to select all columns in a table. This returns a selection function compatible with various Arquero transformation verbs. ```javascript aq.all() ``` -------------------------------- ### table.column(name) Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieves a column instance by its name. The column object offers methods to access its length and get values by row index. ```APIDOC ## table.column(name) ### Description Get the column instance with the given *name*, or `undefined` if does not exist. The returned column object provides a lightweight abstraction over the column storage (such as a backing array), providing a *length* property and *get(row)* method. A column instance may be used across multiple tables and so does _not_ track a table's filter or orderby critera. To access filtered or ordered values, use the table [get](#get), [getter](#getter), or [array](#array) methods. ### Parameters #### Path Parameters - **name** (string) - Required - The column name. ### Request Example ```js const dt = aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) dt.column('b').get(1) // 5 ``` ``` -------------------------------- ### Create Table from Object Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Creates a new table with 'key' and 'value' columns from an object's key-value pairs. This is akin to aq.table({ key: ['a', 'b', 'c'], value: [1, 2, 3] }). ```javascript aq.from({ a: 1, b: 2, c: 3 }) ``` -------------------------------- ### aq.table() Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Creates a new table instance from a set of named columns. Supports specifying column order explicitly. ```APIDOC ## aq.table(columns[, names]) ### Description Create a new table for a set of named columns, optionally including an array of ordered column names. The columns input can be an object or Map with names for keys and columns for values, or an entry array of [name, values] tuples. ### Parameters * **columns** (Object | Map | Array<[string, Array]>): An object or Map providing a named set of column arrays, or an entries array of the form `[[name, values], ...]`. Keys are column name strings; the enumeration order of the keys determines the column indices if the names argument is not provided. Column values should be arrays (or array-like values) of identical length. * **names** (Array): An array of column names, specifying the index order of columns in the table. ### Request Example ```js // create a new table with 2 columns and 3 rows aq.table({ colA: ['a', 'b', 'c'], colB: [3, 4, 5] }) ``` ```js // create a new table, preserving column order for integer names aq.table({ key: ['a', 'b'], 1: [9, 8], 2: [7, 6] }, ['key', '1', '2']) ``` ```js // create a new table from a Map instance const map = new Map() .set('colA', ['a', 'b', 'c']) .set('colB', [3, 4, 5]); aq.table(map) ``` ``` -------------------------------- ### aq.from() Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Creates a new table from existing data structures like arrays of objects or key-value pairs. ```APIDOC ## aq.from(values[, names]) ### Description Create a new table from an existing object, such as an array of objects or a set of key-value pairs. For varied JSON formats, see the [`fromJSON`](#fromJSON) method. ### Parameters * **values** (Array | Object | Map): Data values to populate the table. If array-valued or iterable, imports rows for each non-null value, using the provided column names as keys for each row object. If no *names* are provided, the first non-null object's own keys are used. If an object or a Map, create a two-column table with columns for the input keys and values. * **names** (Array): Column names to include. For object or Map inputs, specifies the key and value column names. Otherwise, specifies the keys to look up on each row object. ### Request Example ```js // from an array, create a new table with two columns and two rows // akin to table({ colA: [1, 3], colB: [2, 4] }) aq.from([ { colA: 1, colB: 2 }, { colA: 3, colB: 4 } ]) ``` ```js // from an object, create a new table with 'key' and 'value columns // akin to table({ key: ['a', 'b', 'c'], value: [1, 2, 3] }) aq.from({ a: 1, b: 2, c: 3 }) ``` ```js // from a Map, create a new table with 'key' and 'value' columns // akin to table({ key: ['d', 'e', 'f'], value: [4, 5, 6] }) aq.from(new Map([ ['d', 4], ['e', 5], ['f', 6] ]) ``` ``` -------------------------------- ### Get Column Values as Array Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieves all values from a specified column as a standard JavaScript Array. This method respects any active table filters or ordering. ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .array('b'); // [ 4, 5, 6 ] ``` ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .filter(d => d.a > 1) .array('b'); // [ 5, 6 ] ``` -------------------------------- ### Column Shorthands for Groupby Source: https://github.com/uwdata/arquero/blob/main/docs/api/expressions.md Demonstrates various shorthands for specifying columns in the groupby verb, including by name, index, range helper, and explicit table expressions. ```javascript table.groupby('colA', 'colB') ``` ```javascript table.groupby(['colA', 'colB']) ``` ```javascript table.groupby(0, 1) ``` ```javascript table.groupby(aq.range(0, 1)) ``` ```javascript table.groupby({ colA: d => d.colA, colB: d => d.colB }) ``` -------------------------------- ### aq.all() Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Selects all columns in a table. Returns a function-valued selection compatible with select, groupby, and join verbs. ```APIDOC ## aq.all() ### Description Selects all columns in a table. Returns a function-valued selection compatible with select, groupby, and join verbs. ### Method ```javascript aq.all() ``` ``` -------------------------------- ### Create Table from Map Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Creates a new table with 'key' and 'value' columns from a Map's entries. This is akin to aq.table({ key: ['d', 'e', 'f'], value: [4, 5, 6] }). ```javascript aq.from(new Map([ ['d', 4], ['e', 5], ['f', 6] ]) ``` -------------------------------- ### Two-Table Join Expression Source: https://github.com/uwdata/arquero/blob/main/docs/api/expressions.md Example of a two-table expression for join verbs, accepting rows from both left and right tables. Aggregate and window functions are not permitted. ```javascript table.join(otherTable, (a, b) => op.equal(a.key, b.key)) ``` -------------------------------- ### Generate Binning Expression Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Use `aq.bin` to create a table expression for uniform binning of numeric values. Options include `maxbins`, `minstep`, `nice`, `offset`, and `step` to control the binning scheme. ```javascript aq.bin('colA', { maxbins: 20 }) ``` -------------------------------- ### Get Row Order Comparator - Arquero Table Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieves the row order comparator function if one has been specified for the table. Returns null if no ordering is defined. ```javascript table.comparator() ``` -------------------------------- ### Get Total Rows - Arquero Table Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieves the total number of rows in the table, including both filtered and unfiltered rows. This value is unaffected by filtering operations. ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .totalRows() // 3 ``` ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .filter(d => d.a > 2) .totalRows() // 3 ``` -------------------------------- ### aq.fromFixed Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Parses a fixed-width file input string into a table. Supports column positions, widths, names, and custom parsing. ```APIDOC ## aq.fromFixed(input, [options]) ### Description Parses a fixed-width file input string into a table. Automatic type inference is performed by default. ### Parameters * *input* (`string`): A text string in a fixed-width format. * *options* (`object`, optional): A fixed-width format options object. * *positions* (`[number, number][]`): Array of [start, end] indices for columns. * *widths* (`number[]`): Array of fixed column widths (ignored if *positions* is specified). * *names* (`string[]`): An array of column names. * *decimal* (`string`): Numeric decimal separator (default `'.'`). * *skip* (`number`): Number of lines to skip (default `0`). * *comment* (`string`): String to identify comment lines. * *autoType* (`boolean`): Enable automatic type inference (default `true`). * *autoMax* (`number`): Maximum number of initial rows for type inference (default `1000`). * *parse* (`Record`): Object of column parsing functions. ### Examples ```js // Create table from fixed-width string aq.fromFixed('a1\nb2', { widths: [1, 1], names: ['u', 'v'] }) ``` ``` -------------------------------- ### Get Number of Active Rows - Arquero Table Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieves the count of currently active (non-filtered) rows. This count can be less than the total rows if filters are applied. ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .numRows() // 3 ``` ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .filter(d => d.a > 2) .numRows() // 1 ``` -------------------------------- ### sample Source: https://github.com/uwdata/arquero/blob/main/docs/api/verbs.md Generates a table from a random sample of rows. If the table is grouped, stratified sampling is performed by sampling separately from each group. ```APIDOC ## sample ### Description Generate a table from a random sample of rows. If the table is grouped, perform [stratified sampling](https://en.wikipedia.org/wiki/Stratified_sampling) by sampling separately from each group. ### Parameters * *size*: The number of samples to draw per group. If number-valued, the same sample size is used for each group. If function-valued, the input should be an aggregate table expression compatible with [rollup](#rollup). * *options*: An options object: * *replace*: Boolean flag (default `false`) to sample with replacement. * *shuffle*: Boolean flag (default `true`) to ensure randomly ordered rows. * *weight*: Column values to use as weights for sampling. Rows will be sampled with probability proportional to their relative weight. The input should be a column name string or a table expression compatible with [derive](#derive). ### Request Example ```js // sample 50 rows without replacement table.sample(50) ``` ```js // sample 100 rows with replacement table.sample(100, { replace: true }) ``` ```js // stratified sampling with dynamic sample size table.groupby('colA').sample(aq.frac(0.5)) ``` ```js // sample twice the number of records in each group, with replacement table.groupby('colA').sample(aq.frac(2), { replace: true }) ``` ``` -------------------------------- ### Load Table from Apache Arrow File Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Loads a table from a byte stream representing an Apache Arrow file. ```javascript // load table from an Apache Arrow file const dt = await aq.fromArrowStream(byteStream); ``` -------------------------------- ### op.dense_rank() Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Window function to assign a dense rank to each value in a group, starting from 1. Peer values receive the same rank, and subsequent ranks do not account for ties. ```APIDOC ## op.dense_rank() ### Description Window function to assign a dense rank to each value in a group, starting from 1. Peer values are assigned the same rank. Subsequent ranks do not reflect the number of prior values: if the first two values tie for rank 1, the third value is assigned rank 2. ### Method N/A (Function call) ### Parameters None ### Request Example ``` op.dense_rank() ``` ### Response N/A (Returns a table expression) ``` -------------------------------- ### op.datetime([year, month, date, hours, minutes, seconds, milliseconds]) Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Creates and returns a new Date value. If no arguments are provided, the current date and time are used. ```APIDOC ## datetime([year, month, date, hours, minutes, seconds, milliseconds]) ### Description Creates and returns a new Date value. If no arguments are provided, the current date and time are used. ### Method `op.datetime([year, month, date, hours, minutes, seconds, milliseconds])` ### Parameters #### Path Parameters - **year** (number) - Optional - The year. - **month** (number) - Optional - The (zero-based) month (default `0`). - **date** (number) - Optional - The date within the month (default `1`). - **hours** (number) - Optional - The hour within the day (default `0`). - **minutes** (number) - Optional - The minute within the hour (default `0`). - **seconds** (number) - Optional - The second within the minute (default `0`). - **milliseconds** (number) - Optional - The milliseconds within the second (default `0`). ### Response - **date** (Date) - The created Date object. ``` -------------------------------- ### Get Grouped Row Indices Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Returns an array of row indices for each group in the table. If the table is not grouped, it behaves like `indices()`. Indices are filtered if the table has been filtered. ```javascript table.partitions() ``` ```javascript table.partitions(false) ``` -------------------------------- ### aq.fromArrowStream Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Returns a Promise to a new table backed by Apache Arrow binary data from a ReadableStream. ```APIDOC ## aq.fromArrowStream ### Description Returns a Promise to a new table backed by Apache Arrow binary data from a ReadableStream. Supports both Arrow IPC `stream` and `file` formats. ### Method `aq.fromArrowStream(stream, [options])` ### Parameters #### Path Parameters * `stream` (ReadableStream) - Required - A ReadableStream of bytes. * `options` (object) - Optional - An Arrow import options object. * `columns` (Select) - Optional - An ordered set of columns to import. * `useBigInt` (boolean) - Optional - Boolean flag (default false) to extract 64-bit integer types as JavaScript `BigInt` values. * `useDate` (boolean) - Optional - Boolean flag (default true) to convert Arrow date and timestamp values to JavaScript Date objects. ### Response #### Success Response (Promise) A Promise that resolves to a new Arquero table backed by Arrow data. #### Response Example (Promise resolving to a Table object representation) ``` -------------------------------- ### Get Filtered Rows Mask - Arquero Table Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Returns the bitset mask representing filtered rows, or null if no filter is active. This can be used for low-level row manipulation. ```javascript table.mask() ``` -------------------------------- ### aq.names(...names) Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Creates a selection helper to rename columns. Returns a function that produces a rename map. ```APIDOC ## aq.names(...names) ### Description Creates a selection helper to rename columns. Returns a function that produces a rename map. This can be used with `table.rename()` or `table.select()`. ### Parameters #### Arguments - **names**: An ordered set of strings to use as the new column names. ### Method ```javascript // Helper to rename the first three columns to 'a', 'b', 'c' aq.names('a', 'b', 'c') // Names can also be passed as arrays aq.names(['a', 'b', 'c']) // Example usage with table.rename() table.rename(aq.names(['a', 'b', 'c'])) // Example usage with table.select() to select and rename first three columns table.select(aq.names(['a', 'b', 'c'])) ``` ``` -------------------------------- ### Get Groupby Specification - Arquero Table Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Returns the groupby specification object if the table has been grouped. This object contains details about group names, accessors, and row indices. ```javascript table.groups() ``` -------------------------------- ### Get Table Size (Active Rows) - Arquero Table Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Provides the number of active (non-filtered) rows, equivalent to `numRows()`. This property access is useful for quick checks. ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .size // 3 ``` ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .filter(d => d.a > 2) .size // 1 ``` -------------------------------- ### select Source: https://github.com/uwdata/arquero/blob/main/docs/api/verbs.md Selects specified columns from a table. ```APIDOC ## select ### Description Selects specified columns from a table. ### Parameters * ...columns: The columns to select. ``` -------------------------------- ### aq.fromCSV Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Creates a table from an input CSV string. Supports various options for parsing, delimiters, headers, and comments. ```APIDOC ## aq.fromCSV(input, [options]) ### Description Creates a table from an input CSV string. ### Parameters * *input* (`string`): A string containing CSV data. * *options* (`object`, optional): An object with parsing options. * *delimiter* (`string`): Column delimiter (default `','`). * *decimal* (`string`): Decimal separator (default `'.'`). * *header* (`boolean`): Whether the CSV has a header row (default `true`). * *names* (`string[]`): Column names for header-less CSV. * *skip* (`number`): Number of lines to skip (default `0`). * *comment* (`string`): String to identify comment lines. * *autoType* (`boolean`): Enable automatic type inference (default `true`). * *autoMax* (`number`): Max rows for type inference (default `1000`). * *parse* (`Record`): Object of column parsing functions. ### Examples ```js // Create table from CSV string aq.fromCSV('a,b\n1,2\n3,4') // Skip commented lines aq.fromCSV('# a comment\na,b\n1,2\n3,4', { comment: '#' }) // Override autoType with custom parser aq.fromCSV('a,b\n00152,2\n30219,4', { parse: { a: String } }) // Parse semi-colon delimited text with comma decimal separator aq.fromCSV('a;b\nu;-1,23\nv;3,45e5', { delimiter: ';', decimal: ',' }) ``` ``` -------------------------------- ### Get Object Values (op.values) Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Retrieves an array of an object's own enumerable property values. Uses the object's 'values' method for Map/Set instances, otherwise Object.values. ```javascript op.values(object) ``` -------------------------------- ### op.ntile(num) Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Window function to assign a quantile value to each value in a group, based on a specified number of buckets. ```APIDOC ## op.ntile(num) ### Description Window function to assign a quantile (e.g., percentile) value to each value in a group. Accepts an integer parameter indicating the number of buckets to use (e.g., 100 for percentiles, 5 for quintiles). ### Method N/A (Function call) ### Parameters #### Path Parameters - **num** (integer) - Required - The number of buckets for ntile calculation. ### Request Example ``` op.ntile(5) ``` ### Response N/A (Returns a table expression) ``` -------------------------------- ### Get Object Keys (op.keys) Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Retrieves an array of an object's own enumerable property names. Uses the object's 'keys' method for Map instances, otherwise Object.keys. ```javascript op.keys(object) ``` -------------------------------- ### aq.loadArrow(url, options) Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Loads data from an Apache Arrow IPC file (stream or file format) from a given URL or file path. Returns a Promise for a table. Supports various options for fetching, decompression, column selection, and data type handling. ```APIDOC ## aq.loadArrow(url, options) ### Description Loads a file in the Apache Arrow IPC binary format from a *url* and returns a Promise for a table. Supports both Arrow IPC `stream` and `file` formats, automatically determining the format type. When invoked in the browser, the Fetch API is used to load the *url*. In node.js, the *url* can also be a local file path. The function handles different URL schemes and local file path resolutions. ### Parameters * *url* (`string`): The url or local file path (node.js only) to load. * *options*: File loading and Arrow formatting options. * *fetch* ([`RequestInit`](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)): Options to pass to the HTTP fetch method when loading a URL. * *decompress* (`'gzip' | 'deflate' | null`): A decompression format to apply. If unspecified, the decompression type is inferred from the file extension (`.gz` for `'gzip'`, `.zz` for `'deflate'`). If no matching extension is found, no decompression is performed. * *columns* (`Select`): An ordered set of columns to import. The input may consist of: column name strings, column integer indices, objects with current column names as keys and new column names as values (for renaming), or a selection helper function such as [all](#all), [not](#not), or [range](#range). * *useBigInt* (`boolean`): Boolean flag (default `false`) to extract 64-bit integer types as JavaScript `BigInt` values. For Flechette tables, the default is to coerce 64-bit integers to JavaScript numbers and raise an error if the number is out of range. This option is only applied when parsing IPC binary data, otherwise the settings of the provided table instance are used. * *useDate* (`boolean`): Boolean flag (default `true`) to convert Arrow date and timestamp values to JavaScript Date objects. Otherwise, numeric timestamps are used. This option is only applied when parsing IPC binary data, otherwise the settings of the provided table instance are used. * *useDecimalBigInt* (`boolean`): Boolean flag (default `false`) to extract Arrow decimal-type data as BigInt values, where fractional digits are scaled to integers. Otherwise, decimals are (sometimes lossily) converted to floating-point numbers (default). This option is only applied when parsing IPC binary data, otherwise the settings of the provided table instance are used. * *useMap* (`boolean`): Boolean flag (default `false`) to represent Arrow Map data as JavaScript `Map` values. For Flechette tables, the default is to produce an array of `[key, value]` arrays. This option is only applied when parsing IPC binary data, otherwise the settings of the provided table instance are used. * *useProxy* (`boolean`): Boolean flag (default `false`) to extract Arrow Struct values and table row objects using zero-copy proxy objects that extract data from underlying Arrow batches. The proxy objects can improve performance and reduce memory usage, but do not support property enumeration (`Object.keys`, `Object.values`, `Object.entries`) or spreading (`{ ...object }`). This option is only applied when parsing IPC binary data, otherwise the settings of the provided table instance are used. ### Request Example ```js // load table from an Apache Arrow file const dt = await aq.loadArrow('data/table.arrow'); ``` ``` -------------------------------- ### Get Specific Cell Value Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieves the value of a specific cell identified by column name and row index. The row index is relative to the current filter and order criteria. ```javascript const dt = aq.table({ a: [1, 2, 3], b: [4, 5, 6] }); dt.get('a', 0) // 1 dt.get('a', 2) // 3 ``` ```javascript const dt = aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .orderby(aq.desc('b')); dt.get('a', 0) // 3 dt.get('a', 2) // 1 ``` -------------------------------- ### aq.fromFixedStream Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Parses a fixed-width file stream and returns a Promise to a table. Supports automatic type inference and custom parsing for input values. ```APIDOC ## aq.fromFixedStream ### Description Parse a fixed-width file *stream* and return a Promise to a table. By default, automatic type inference is performed for input values; string values that match the [ISO standard date format](https://en.wikipedia.org/wiki/ISO_8601) are parsed into JavaScript Date objects. To disable this behavior set *options.autoType* to `false`, which will cause all columns to be loaded as strings. To perform custom parsing of input column values, use *options.parse*. This method performs parsing only. To specify a URL or file to load, use [loadFixed](#loadFixed). ### Parameters * *stream*: A [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) of text. * *options*: A fixed-width format options object. ``` -------------------------------- ### Get Column Values with Typed Array Source: https://github.com/uwdata/arquero/blob/main/docs/api/table.md Retrieves column values and instantiates them into a specified typed array (e.g., Int32Array). Ensure the data type is compatible to avoid errors or truncation. ```javascript aq.table({ a: [1, 2, 3], b: [4, 5, 6] }) .array('b', Int32Array); // Int32Array.of(4, 5, 6) ``` -------------------------------- ### Get Object Entries (op.entries) Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Retrieves an array of an object's own enumerable string-keyed [key, value] pairs. Uses the object's 'entries' method for Map/Set instances, otherwise Object.entries. ```javascript op.entries(object) ``` -------------------------------- ### aq.bin Source: https://github.com/uwdata/arquero/blob/main/docs/api/index.md Generates a table expression for uniform binning of number values, usable in table transformation verbs. ```APIDOC ## aq.bin(name, [options]) ### Description Generate a table expression that performs uniform binning of number values. The resulting string can be used as part of the input to table transformation verbs. ### Parameters * *name*: The name of the column to bin. * *options*: A binning scheme options object: * *maxbins*: The maximum number of bins. * *minstep*: The minimum step size between bins. * *nice*: Boolean flag (default `true`) indicating if bins should snap to "nice" human-friendly values such as multiples of ten. * *offset*: Step offset for bin boundaries. The default (`0`) floors to the lower bin boundary. A value of `1` snaps one step higher to the upper bin boundary, and so on. * *step*: The exact step size to use between bins. If specified, the *maxbins* and *minstep* options are ignored. ### Request Example ```js aq.bin('colA', { maxbins: 20 }) ``` ``` -------------------------------- ### op.lead(field, offset, defaultValue) Source: https://github.com/uwdata/arquero/blob/main/docs/api/op.md Window function to retrieve a succeeding value from a specified field, with optional offset and default value. ```APIDOC ## op.lead(field[, offset, defaultValue]) ### Description Window function to assign a value that follows the current value by a specified number of positions. If no such value exists, returns a default value instead. ### Method N/A (Function call) ### Parameters #### Path Parameters - **field** (column name string or expression) - Required - The data column or derived field. - **offset** (integer) - Optional - The lead offset (default `1`) from the current value. - **defaultValue** (any) - Optional - The default value (default `undefined`). ### Request Example ``` op.lead('value', 2, null) ``` ### Response N/A (Returns a table expression) ```