Skip to main content

Data

Creating, loading, querying, manipulating, joining tables.

Constructors

new Data()

new Data(): Data

Returns

Data

Properties

PropertyModifierTypeDefault value
dbpublicDb...
demopublicDemoDatasets...
filespublicFiles...

Methods

callQuery()

callQuery(queryName, queryParameters, adHoc): Promise <FuncCall>

Parameters

ParameterTypeDefault valueDescription
queryNamestringundefined-
queryParametersnull | objectnull-
adHocbooleanfalse

Deprecated

Parameter adHoc will be removed soon.

Returns

Promise <FuncCall>

Source

src/data.ts:264


compareTables()

compareTables(t1, t2, keyColumns1, keyColumns2, valueColumns1, valueColumns2, addToWorkspace): object

Opens the visual table comparison tool. Sample: https://public.datagrok.ai/js/samples/data-frame/compare-tables

Parameters

ParameterTypeDefault value
t1DataFrameundefined
t2DataFrameundefined
keyColumns1string[]undefined
keyColumns2string[]undefined
valueColumns1string[]undefined
valueColumns2string[]undefined
addToWorkspacebooleanfalse

Returns

object

MemberType
changedColumnsnumber
changedValuesnumber
diffGridGrid
diffTableDataFrame
missingRowsnumber
t1MissingRowsnumber
t2MissingRowsnumber

Source

src/data.ts:187


detectSemanticTypes()

detectSemanticTypes(t): Promise<void>

Parameters

ParameterType
tDataFrame

Returns

Promise<void>

Source

src/data.ts:273


getDemoTable()

getDemoTable(path): Promise <DataFrame>

Parameters

ParameterType
pathstring

Returns

Promise <DataFrame>

Source

src/data.ts:151


joinTables()

joinTables(t1, t2, keyColumns1, keyColumns2, valueColumns1, valueColumns2, joinType, inPlace): DataFrame

Merges two tables by the specified key columns.

Parameters

ParameterTypeDefault valueDescription
t1DataFrameundefineda table to join
t2DataFrameundefineda table to join
keyColumns1string[]undefinedkey column names from the first table
keyColumns2string[]undefinedkey column names from the second table
valueColumns1null | string[]nullcolumn names to copy from the first table. Pass null to add all columns, an empty array [] to not add any columns, or an array with column names to add them specifically.
valueColumns2null | string[]nullcolumn names to copy from the second table
joinType"left" | "right" | "inner" | "outer"JOIN_TYPE.INNERinner, outer, left, or right. See [DG.JOIN_TYPE]
inPlacebooleanfalsemerges content in-place into the source table

Returns

DataFrame

Sample: https://public.datagrok.ai/js/samples/data-frame/join-link/join-tables

Source

src/data.ts:212


linkTables()

linkTables(t1, t2, keyColumns1, keyColumns2, linkTypes, initialSync): void

Links tables by the specified key columns using the specified link types (such as "current row to filter", see DG.SYNC_TYPE). Tables are synchronized on the first change, set the initialSync option to reflect the current table state according to the sync type.

Parameters

ParameterTypeDefault value
t1DataFrameundefined
t2DataFrameundefined
keyColumns1string[]undefined
keyColumns2string[]undefined
linkTypes("row to row" | "row to selection" | "row to filter" | "mouse-over to selection" | "mouse-over to filter" | "filter to filter" | "filter to selection" | "selection to filter" | "selection to selection")[]undefined
initialSyncbooleanfalse

Returns

void

Source

src/data.ts:179


loadTable()

loadTable(csvUrl): Promise <DataFrame>

Loads table from the specified URL. Sample: https://public.datagrok.ai/js/samples/data-access/load-csv

Parameters

ParameterTypeDescription
csvUrlstring

Returns

Promise <DataFrame>

Source

src/data.ts:171


openTable()

openTable(id): Promise <DataFrame>

Opens a table by its id. Sample: https://public.datagrok.ai/js/samples/data-access/open-table-by-id

Parameters

ParameterTypeDescription
idstringtable GUID

Returns

Promise <DataFrame>

Source

src/data.ts:222


parseCsv()

parseCsv(csv, options?): DataFrame

Parses the CSV string.

Parameters

ParameterTypeDescription
csvstringThe content of the comma-separated values file.
options?CsvImportOptions

Returns

DataFrame

Source

src/data.ts:161


query()

query<T>(queryName, queryParameters, adHoc): Promise<T>

Executes a Datagrok query and returns the result as the specified type.

Type parameters

Type parameterValueDescription
TDataFrameThe expected return type of the query (defaults to DataFrame).

Parameters

ParameterTypeDefault valueDescription
queryNamestringundefined

The fully qualified name of the query to execute

(e.g., "DbTests:PostgresqlScalarInt").

queryParametersnull | objectnull

Optional key-value pairs that will be passed as

parameters to the query. Defaults to null if no parameters are needed.

adHocbooleanfalse

Deprecated. Indicates whether the query should be

executed in ad-hoc mode. This parameter will be removed soon and should

not be used.

Returns

Promise<T>

A promise that resolves to the query result, converted to type T.

Examples

// Returns a number
const count = await grok.data.query<number>("DbTests:PostgresqlScalarInt");
// Returns a string
const text = await grok.data.query<string>("DbTests:PostgresqlScalarStr");
// Returns a DataFrame (default)
const df = await grok.data.query("DbTests:PostgresqlTable");

Sample: {@link https://public.datagrok.ai/js/samples/data-access/parameterized-query}

Source

src/data.ts:255


testData()

testData(dataset, rows, columns): DataFrame

Creates a generic dataset with the defined number of rows and columns. [dataset] allowed values: "wells" - experimental plate wells: barcode, row, col, pos, volume, concentration, role "demog" - clinical study demographics data: subj, study, site, sex, race, disease, start date "biosensor": wearable sensor data: time, x, y, z, temp, eda "random walk": random walk data for the specified number of dimensions "geo": geographic coordinates given as latitude/longitude pairs: lat, lng, value

Parameters

ParameterTypeDefault value
dataset"wells" | "demog" | "biosensor" | "random walk" | "geo" | "molecules" | "dose-response"undefined
rowsnumber10000
columnsnumber3

Returns

DataFrame

Source

src/data.ts:147