Skip to main content

Data

Defined in: js-api/src/data.ts:306

Constructors​

Constructor​

new Data(): Data

Returns​

Data

Properties​

PropertyModifierTypeDefined in
dbpublicDbjs-api/src/data.ts:309
demopublicDemoDatasetsjs-api/src/data.ts:307
filespublicFilesjs-api/src/data.ts:308

Methods​

callQuery()​

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

Defined in: js-api/src/data.ts:428

Parameters​

ParameterTypeDefault valueDescription
queryNamestringundefined-
queryParametersobject | nullnull-
adHocbooleanfalseDeprecated The parameter is ignored. Removed in 1.29.

Returns​

Promise<FuncCall>


compareTables()​

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

Defined in: js-api/src/data.ts:356

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

NameTypeDefined in
changedColumnsnumberjs-api/src/data.ts:357
changedValuesnumberjs-api/src/data.ts:358
diffGridGridjs-api/src/data.ts:360
diffTableDataFramejs-api/src/data.ts:359
missingRowsnumberjs-api/src/data.ts:361
t1MissingRowsnumberjs-api/src/data.ts:362
t2MissingRowsnumberjs-api/src/data.ts:363

detectSemanticTypes()​

detectSemanticTypes(t): Promise<void>

Defined in: js-api/src/data.ts:437

Parameters​

ParameterType
tDataFrame

Returns​

Promise<void>


getDemoTable()​

getDemoTable(path): Promise<DataFrame>

Defined in: js-api/src/data.ts:323

Parameters​

ParameterType
pathstring

Returns​

Promise<DataFrame>


joinTables()​

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

Defined in: js-api/src/data.ts:379

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
valueColumns1string[] | nullnullcolumn 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.
valueColumns2string[] | nullnullcolumn names to copy from the second table
joinType"inner" | "outer" | "left" | "right"JOIN_TYPE.INNERinner, outer, left, or right. See [DG.JOIN_TYPE]
inPlacebooleanfalsemerges content in-place into the source table Sample: https://public.datagrok.ai/js/samples/data-frame/join-link/join-tables

Returns​

DataFrame


linkTables()​

Call Signature​

linkTables(t1, t2, keyColumns1, keyColumns2, linkTypes, options?): void

Defined in: js-api/src/data.ts:345

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​
ParameterType
t1DataFrame
t2DataFrame
keyColumns1string[]
keyColumns2string[]
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")[]
options?LinkTablesOptions
Returns​

void

Call Signature​

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

Defined in: js-api/src/data.ts:346

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​
ParameterType
t1DataFrame
t2DataFrame
keyColumns1string[]
keyColumns2string[]
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")[]
initialSync?boolean
filterAllOnNoRowsSelected?boolean
Returns​

void


loadTable()​

loadTable(csvUrl): Promise<DataFrame>

Defined in: js-api/src/data.ts:337

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

Parameters​

ParameterType
csvUrlstring

Returns​

Promise<DataFrame>


openTable()​

openTable(id): Promise<DataFrame>

Defined in: js-api/src/data.ts:387

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>


parseCsv()​

parseCsv(csv, options?): DataFrame

Defined in: js-api/src/data.ts:330

Parses the CSV string.

Parameters​

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

Returns​

DataFrame


query()​

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

Defined in: js-api/src/data.ts:419

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

Type Parameters​

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

Parameters​

ParameterTypeDefault valueDescription
queryNamestringundefinedThe fully qualified name of the query to execute (e.g., "DbTests:PostgresqlScalarInt").
queryParametersobject | nullnullOptional key-value pairs that will be passed as parameters to the query. Defaults to null if no parameters are needed.
adHocbooleanfalseDeprecated. 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/db/parameterized-query}

testData()​

testData(dataset, rows?, columns?): DataFrame

Defined in: js-api/src/data.ts:319

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