### 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