Skip to main content

Data

Defined in: src/data.ts:138

Creating, loading, querying, manipulating, joining tables.

Constructors

Constructor

new Data(): Data

Returns

Data

Properties

PropertyModifierTypeDefined in
dbpublicDbsrc/data.ts:141
demopublicDemoDatasetssrc/data.ts:139
filespublicFilessrc/data.ts:140

Methods

callQuery()

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

Defined in: src/data.ts:264

Parameters

ParameterTypeDefault valueDescription
queryNamestringundefined-
queryParametersobject | nullnull-
adHocbooleanfalseDeprecated Parameter adHoc will be removed soon.

Returns

Promise<FuncCall>


compareTables()

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

Defined in: src/data.ts:189

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
changedColumnsnumbersrc/data.ts:190
changedValuesnumbersrc/data.ts:191
diffGridGridsrc/data.ts:193
diffTableDataFramesrc/data.ts:192
missingRowsnumbersrc/data.ts:194
t1MissingRowsnumbersrc/data.ts:195
t2MissingRowsnumbersrc/data.ts:196

detectSemanticTypes()

detectSemanticTypes(t): Promise<void>

Defined in: src/data.ts:273

Parameters

ParameterType
tDataFrame

Returns

Promise<void>


getDemoTable()

getDemoTable(path): Promise<DataFrame>

Defined in: src/data.ts:157

Parameters

ParameterType
pathstring

Returns

Promise<DataFrame>


joinTables()

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

Defined in: src/data.ts:213

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"left" | "right" | "inner" | "outer"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()

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

Defined in: src/data.ts:181

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
filterAllOnNoRowsSelectedbooleanfalse

Returns

void


loadTable()

loadTable(csvUrl): Promise<DataFrame>

Defined in: src/data.ts:173

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: src/data.ts:222

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: src/data.ts:166

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: src/data.ts:255

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/parameterized-query}

testData()

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

Defined in: src/data.ts:153

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