Skip to main content

Class: Data

dg.Data

Creating, loading, querying, manipulating, joining tables.

Constructors

constructor

new Data()

Properties

db

db: Db

Defined in

src/data.ts:115


demo

demo: DemoDatasets

Defined in

src/data.ts:113


files

files: Files

Defined in

src/data.ts:114

Methods

callQuery

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

Parameters

NameTypeDefault value
queryNamestringundefined
queryParametersnull | objectnull
adHocbooleanfalse

Returns

Promise<FuncCall>

Defined in

src/data.ts:216


compareTables

compareTables(t1, t2, keyColumns1, keyColumns2, valueColumns1, valueColumns2): Object

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

Parameters

NameType
t1DataFrame
t2DataFrame
keyColumns1string[]
keyColumns2string[]
valueColumns1string[]
valueColumns2string[]

Returns

Object

NameType
changedColumnsnumber
changedValuesnumber
diffTableDataFrame
missingRowsnumber
t1MissingRowsnumber
t2MissingRowsnumber

Defined in

src/data.ts:167


detectSemanticTypes

detectSemanticTypes(t): Promise<void>

Parameters

NameType
tDataFrame

Returns

Promise<void>

Defined in

src/data.ts:220


getDemoTable

getDemoTable(path): Promise<DataFrame>

Parameters

NameType
pathstring

Returns

Promise<DataFrame>

Defined in

src/data.ts:131


joinTables

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

Merges two tables by the specified key columns.

Parameters

NameTypeDefault 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

Defined in

src/data.ts:195


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

NameTypeDefault 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

Defined in

src/data.ts:159


loadTable

loadTable(csvUrl): Promise<DataFrame>

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

Parameters

NameType
csvUrlstring

Returns

Promise<DataFrame>

Defined in

src/data.ts:151


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

NameTypeDescription
idstringtable GUID

Returns

Promise<DataFrame>

Defined in

src/data.ts:205


parseCsv

parseCsv(csv, options?): DataFrame

Parses the CSV string.

Parameters

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

Returns

DataFrame

Defined in

src/data.ts:141


query

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

Executes a parameterized query. Sample: https://public.datagrok.ai/js/samples/data-access/parameterized-query

Parameters

NameTypeDefault value
queryNamestringundefined
queryParametersnull | objectnull
adHocbooleanfalse

Returns

Promise<any>

Defined in

src/data.ts:212


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

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

Returns

DataFrame

Defined in

src/data.ts:127