Data
Creating, loading, querying, manipulating, joining tables.
Constructors
new Data()
new Data():
Data
Returns
Properties
| Property | Modifier | Type | Default value |
|---|---|---|---|
db | public | Db | ... |
demo | public | DemoDatasets | ... |
files | public | Files | ... |
Methods
callQuery()
callQuery(
queryName,queryParameters,adHoc):Promise<FuncCall>
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
queryName | string | undefined | - |
queryParameters | null | object | null | - |
adHoc | boolean | false | Deprecated Parameter adHoc will be removed soon. |
Returns
Promise <FuncCall>
Source
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
| Parameter | Type | Default value |
|---|---|---|
t1 | DataFrame | undefined |
t2 | DataFrame | undefined |
keyColumns1 | string[] | undefined |
keyColumns2 | string[] | undefined |
valueColumns1 | string[] | undefined |
valueColumns2 | string[] | undefined |
addToWorkspace | boolean | false |
Returns
object
| Member | Type |
|---|---|
changedColumns | number |
changedValues | number |
diffGrid | Grid |
diffTable | DataFrame |
missingRows | number |
t1MissingRows | number |
t2MissingRows | number |
Source
detectSemanticTypes()
detectSemanticTypes(
t):Promise<void>
Parameters
| Parameter | Type |
|---|---|
t | DataFrame |
Returns
Promise<void>
Source
getDemoTable()
getDemoTable(
path):Promise<DataFrame>
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
Promise <DataFrame>
Source
joinTables()
joinTables(
t1,t2,keyColumns1,keyColumns2,valueColumns1,valueColumns2,joinType,inPlace):DataFrame
Merges two tables by the specified key columns.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
t1 | DataFrame | undefined | a table to join |
t2 | DataFrame | undefined | a table to join |
keyColumns1 | string[] | undefined | key column names from the first table |
keyColumns2 | string[] | undefined | key column names from the second table |
valueColumns1 | null | string[] | null | column 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. |
valueColumns2 | null | string[] | null | column names to copy from the second table |
joinType | "left" | "right" | "inner" | "outer" | JOIN_TYPE.INNER | inner, outer, left, or right. See [DG.JOIN_TYPE] |
inPlace | boolean | false | merges content in-place into the source table |
Returns
Sample: https://public.datagrok.ai/js/samples/data-frame/join-link/join-tables
Source
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
| Parameter | Type | Default value |
|---|---|---|
t1 | DataFrame | undefined |
t2 | DataFrame | undefined |
keyColumns1 | string[] | undefined |
keyColumns2 | string[] | 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 |
initialSync | boolean | false |
Returns
void
Source
loadTable()
loadTable(
csvUrl):Promise<DataFrame>
Loads table from the specified URL. Sample: https://public.datagrok.ai/js/samples/data-access/load-csv
Parameters
| Parameter | Type | Description |
|---|---|---|
csvUrl | string |
Returns
Promise <DataFrame>
Source
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
| Parameter | Type | Description |
|---|---|---|
id | string | table GUID |
Returns
Promise <DataFrame>
Source
parseCsv()
parseCsv(
csv,options?):DataFrame
Parses the CSV string.
Parameters
| Parameter | Type | Description |
|---|---|---|
csv | string | The content of the comma-separated values file. |
options? | CsvImportOptions |
Returns
Source
query()
query<
T>(queryName,queryParameters,adHoc):Promise<T>
Executes a Datagrok query and returns the result as the specified type.
Type parameters
| Type parameter | Value | Description |
|---|---|---|
T | DataFrame | The expected return type of the query (defaults to DataFrame). |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
queryName | string | undefined | The fully qualified name of the query to execute (e.g., |
queryParameters | null | object | null | Optional key-value pairs that will be passed as parameters to the query. Defaults to |
adHoc | boolean | false | 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
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
| Parameter | Type | Default value |
|---|---|---|
dataset | "wells" | "demog" | "biosensor" | "random walk" | "geo" | "molecules" | "dose-response" | undefined |
rows | number | 10000 |
columns | number | 3 |