Skip to main content

DataFrame

DataFrame is a high-performance, easy to use tabular structure with strongly-typed columns of different types.

In the API, the terms "Table" and "DataFrame" are used interchangeably.

Usage samples: https://public.datagrok.ai/js/samples/data-frame/manipulate Usage details: https://datagrok.ai/help/develop/advanced/data-frame Implementation details: https://datagrok.ai/help/develop/admin/architecture#in-memory-database

Constructors

new DataFrame()

new DataFrame(dart): DataFrame

Parameters

ParameterType
dartany

Returns

DataFrame

Source

src/dataframe.ts:121

Properties

PropertyModifierType
_dialogsprivateundefined | DataFrameDialogHelper
_metapublicundefined | DataFrameMetaHelper
_plotprivateundefined | DataFramePlotHelper
columnspublicColumnList
dartreadonlyany
filterpublicBitSet
rowspublicRowList
tagspublicany
temppublicany

Accessors

currentCell

get currentCell(): Cell

Current cell. Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements

set currentCell(cell): void

Current cell. Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements

Parameters

ParameterType
cellCell

Returns

Cell

Source

src/dataframe.ts:371


currentCol

get currentCol(): Column<any, any>

Current column. Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements

set currentCol(col): void

Current column. Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements

Parameters

ParameterType
colColumn<any, any>

Returns

Column<any, any>

Source

src/dataframe.ts:359


currentRow

get currentRow(): Row

Current row. Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements

set currentRow(row): void

Parameters

ParameterType
rowRow

Returns

Row

Source

src/dataframe.ts:346


currentRowIdx

get currentRowIdx(): number

Index of the current row.

set currentRowIdx(idx): void

Parameters

ParameterType
idxnumber

Returns

number

Source

src/dataframe.ts:350


dialogs

get dialogs(): DataFrameDialogHelper

Returns

DataFrameDialogHelper

Source

src/dataframe.ts:212


id

get id(): string

Id of the dataframe.

set id(id): void

Parameters

ParameterType
idstring

Returns

string

Source

src/dataframe.ts:545


meta

get meta(): DataFrameMetaHelper

A helper to conveniently access certain metadata properties stored in tags

Returns

DataFrameMetaHelper

Source

src/dataframe.ts:199


mouseOverRowIdx

get mouseOverRowIdx(): number

Index of the mouse-over row.

set mouseOverRowIdx(idx): void

Parameters

ParameterType
idxnumber

Returns

number

Source

src/dataframe.ts:354


name

get name(): string

Name of the dataframe.

set name(s): void

Parameters

ParameterType
sstring

Returns

string

Source

src/dataframe.ts:229


onColumnNameChanged

get onColumnNameChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:490


onColumnSelectionChanged

get onColumnSelectionChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:493


onColumnsAdded

get onColumnsAdded(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:499


onColumnsChanged

get onColumnsChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:496


onColumnsRemoved

get onColumnsRemoved(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:502


onCurrentCellChanged

get onCurrentCellChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements

Returns

Observable<any>

Source

src/dataframe.ts:478


onCurrentColChanged

get onCurrentColChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements

Returns

Observable<any>

Source

src/dataframe.ts:472


onCurrentRowChanged

get onCurrentRowChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements

Returns

Observable<any>

Source

src/dataframe.ts:466


onDataChanged

get onDataChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:523


onFilterChanged

get onFilterChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:532


onMetadataChanged

get onMetadataChanged(): Observable <EventData <MapChangeArgs<string, string>>>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable <EventData <MapChangeArgs<string, string>>>

Source

src/dataframe.ts:487


onMouseOverColChanged

get onMouseOverColChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:475


onMouseOverRowChanged

get onMouseOverRowChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:469


onMouseOverRowGroupChanged

get onMouseOverRowGroupChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:481


onNameChanged

get onNameChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:484


onRowsAdded

get onRowsAdded(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:505


onRowsFiltered

get onRowsFiltered(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:511


onRowsFiltering

get onRowsFiltering(): Observable<any>

Returns

Observable<any>

Source

src/dataframe.ts:514


onRowsRemoved

get onRowsRemoved(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:508


onSelectionChanged

get onSelectionChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:529


onSemanticTypeDetected

get onSemanticTypeDetected(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/advanced/semantic-type-detection

Returns

Observable<any>

Source

src/dataframe.ts:520


onSemanticTypeDetecting

get onSemanticTypeDetecting(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/advanced/semantic-type-detection

Returns

Observable<any>

Source

src/dataframe.ts:517


onValuesChanged

get onValuesChanged(): Observable<any>

Sample: https://public.datagrok.ai/js/samples/data-frame/events/events

Returns

Observable<any>

Source

src/dataframe.ts:463


plot

get plot(): DataFramePlotHelper

A helper for creating plots for this dataframe

Returns

DataFramePlotHelper

Source

src/dataframe.ts:206


rowCount

get rowCount(): number

Returns number of rows in the table.

Returns

number

Source

src/dataframe.ts:219


selection

get selection(): BitSet

Returns a BitSet with selected rows.

Returns

BitSet

Source

src/dataframe.ts:224

Methods

_event()

_event(event): Observable<any>

Parameters

ParameterType
eventstring

Returns

Observable<any>

Source

src/dataframe.ts:454


_exportReopen()

_exportReopen(): DataFrame

Returns

DataFrame

Source

src/dataframe.ts:561


append()

append(t2, inPlace, columnsToAppend): DataFrame

Appends two tables ('union' in SQL).

Parameters

ParameterTypeDefault valueDescription
t2DataFrameundefined
inPlacebooleanfalsewhether to create a new table, or modify 'this' one.
columnsToAppendnull | string[]null

Returns

DataFrame

Source

src/dataframe.ts:446


appendMerge()

appendMerge(t): void

Parameters

ParameterType
tDataFrame

Returns

void

Source

src/dataframe.ts:450


cell()

cell(idx, name): Cell

Returns a Cell with the specified row and column.

Parameters

ParameterTypeDescription
idxnumberRow index.
namestringColumn name.

Returns

Cell

Source

src/dataframe.ts:286


changeColumnType()

changeColumnType(column, newType, format): Column<any, any>

Converts a column with the specified name to [newType], removes the original column from its dataframe and adds the new column to it.

Parameters

ParameterTypeDefault valueDescription
columnstring | Column<any, any>undefined
newType"string" | "bigint" | "object" | "int" | "double" | "bool" | "byte_array" | "datetime" | "qnum" | "dataframe"undefined
formatnull | stringnullnumber format

Returns

Column<any, any>

See

COLUMN_TYPE

Source

src/dataframe.ts:387


clone()

clone(rowMask, columnIds, saveSelection): DataFrame

Creates a new dataframe from the specified row mask and a list of columns.

Parameters

ParameterTypeDefault valueDescription
rowMasknull | BitSetnullRows to include.
columnIdsnull | string[]nullColumns to include.
saveSelectionbooleanfalseWhether selection should be saved.

Returns

DataFrame

Source

src/dataframe.ts:340


col()

col(nameOrIndex): null | Column<any, any>

Returns a Column with the specified name.

Parameters

ParameterTypeDescription
nameOrIndexstring | numberColumn name.

Returns

null | Column<any, any>

Source

src/dataframe.ts:273


fireValuesChanged()

fireValuesChanged(): void

Returns

void

Source

src/dataframe.ts:534


get()

get(name, idx): any

Returns idx-th value of the specified columns.

Parameters

ParameterTypeDescription
namestringColumn name.
idxnumberRow index.

Returns

any

Source

src/dataframe.ts:258


getCol()

getCol(name): Column<any, any>

Same as col, but throws Error if column is not found

Parameters

ParameterTypeDescription
namestringColumn name.

Returns

Column<any, any>

Source

src/dataframe.ts:293


getDensity()

getDensity(xBins, yBins, xColName, yColName): Int32Array

Parameters

ParameterType
xBinsnumber
yBinsnumber
xColNamestring
yColNamestring

Returns

Int32Array

Source

src/dataframe.ts:553


getSortedOrder()

getSortedOrder(sortByColumnIds, sortOrders, rowMask): Int32Array

Returns [Int32Array] that contains sorted order, or null for unsorted (original) order. See also Column.getSortedOrder. Sample: https://public.datagrok.ai/js/samples/data-frame/sorting/sorted-order

Parameters

ParameterTypeDefault valueDescription
sortByColumnIdsColumnId[]undefinedCollection of [Column]s to use as keys for sorting.
sortOrdersnull | boolean[]nullList of sort orders for [sortByCols]. True == ascending.
rowMasknull | BitSetnullMask of the rows to sort. Result array will contain [rowIndexes.length] elements.

Returns

Int32Array

Source

src/dataframe.ts:400


getTableInfo()

getTableInfo(): TableInfo

Returns

TableInfo

Source

src/dataframe.ts:557


getTag()

getTag(tag): null | string

Returns the value of the specified tag, or null if it does not exist.

Parameters

ParameterType
tagstring

Returns

null | string

Source

src/dataframe.ts:234


groupBy()

groupBy(columnNames): GroupByBuilder

Begins building a query, using the specified columns as keys.

Parameters

ParameterTypeDefault valueDescription
columnNamesstring[][]Names of the columns to be used as keys.

Returns

GroupByBuilder

Source

src/dataframe.ts:408


join()

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

Merges two tables by the specified key columns.

Parameters

ParameterTypeDefault valueDescription
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/dataframe.ts:435


onEvent()

onEvent(event): Observable<any>

Parameters

ParameterType
eventstring

Returns

Observable<any>

Source

src/dataframe.ts:458


row()

row(rowIndex): Row

Returns i-th row. NOTE: Do not use in performance-critical paths, consider accessing values via the Column instance.

Parameters

ParameterType
rowIndexnumber

Returns

Row

Source

src/dataframe.ts:251


set()

set(name, idx, value): void

Sets idx-th value of the specified columns.

Parameters

ParameterTypeDescription
namestringColumn name.
idxnumberRow index.
valueanyValue.

Returns

void

Source

src/dataframe.ts:266


setTag()

setTag(tag, value): DataFrame

Sets a tag to the specified value.

Parameters

ParameterTypeDescription
tagstringKey.
valuestringValue.

Returns

DataFrame

Source

src/dataframe.ts:241


toByteArray()

toByteArray(): Uint8Array

Exports dataframe to binary

Returns

Uint8Array

Source

src/dataframe.ts:332


toCsv()

toCsv(options?, grid?): string

Exports the content to comma-separated-values format.

Parameters

ParameterTypeDescription
options?CsvExportOptionsoptions for the export
grid?Gridif specified, takes visible columns, column and row order from the grid.

Returns

string

Source

src/dataframe.ts:304


toCsvEx()

toCsvEx(options?, grid?): Promise<string>

Exports the content to comma-separated-values format asynchronously with converting the molblock columns to smiles if specified.

Parameters

ParameterTypeDescription
options?CsvExportOptionsoptions for the export
grid?Gridif specified, takes visible columns, column and row order from the grid.

Returns

Promise<string>

Source

src/dataframe.ts:313


toJson()

toJson(): any[]

Converts the contents to array of objects, with column names as keys. Keep in mind that the internal DataFrame format is far more efficient than JSON, so use it only as a convenience for working with relatively small datasets.

Returns

any[]

Source

src/dataframe.ts:320


toString()

toString(): string

Returns

string

Source

src/dataframe.ts:539


unpivot()

unpivot(copyColumnNames, mergeColumnNames, categoryColumnName, valueColumnName): DataFrame

Unpivots the table (converts from 'wide' representation with many columns to 'tall and skinny').

Parameters

ParameterTypeDefault valueDescription
copyColumnNamesstring[]undefinedcolumns to copy
mergeColumnNamesstring[]undefined

columns to merge. Column name will become a value in the [categoryColumnName] column,

and column value will become a value in the [valueColumnName] column.

categoryColumnNamestring'Category'-
valueColumnNamestring'Value'-

Returns

DataFrame

Source

src/dataframe.ts:418


create()

static create(rowCount, name?): DataFrame

Creates a DataFrame with the specified number of rows and no columns.

Parameters

ParameterTypeDefault value
rowCountnumber0
name?stringundefined

Returns

DataFrame

Source

src/dataframe.ts:131


fromByteArray()

static fromByteArray(byteArray): DataFrame

Parameters

ParameterType
byteArrayUint8Array

Returns

DataFrame

Source

src/dataframe.ts:138


fromColumns()

static fromColumns(columns): DataFrame

Creates a DataFrame from the specified columns. All columns should be of the same length.

Parameters

ParameterType
columnsColumn<any, any>[]

Returns

DataFrame

Source

src/dataframe.ts:143


fromCsv()

static fromCsv(csv, options?): DataFrame

Constructs DataFrame from a comma-separated values string

Parameters

ParameterTypeDescription
csvstring

The content of the comma-separated values file.

https://dev.datagrok.ai/script/samples/javascript/data-frame/construction/create-from-csv

options?CsvImportOptions-

Returns

DataFrame

Source

src/dataframe.ts:186


fromJson()

static fromJson(json): DataFrame

Constructs DataFrame from the specified JSON string.

Parameters

ParameterTypeDescription
jsonstring

JSON document.

https://dev.datagrok.ai/script/samples/javascript/data-frame/construction/create-from-json

Returns

DataFrame

Source

src/dataframe.ts:194


fromObjects()

static fromObjects(list): undefined | DataFrame

Creates a [DataFrame] from a list of objects by using object keys as column names, and object values as values.

NOTE: The implementation converts the values to strings first and then parses it, so do not use this method in performance-critical paths (for instance when the number of objects could be big), consider using fromColumns instead.

Parameters

ParameterTypeDescription
listobject[]

List of objects.

https://dev.datagrok.ai/script/samples/javascript/data-frame/construction/create-from-objects

Returns

undefined | DataFrame

Source

src/dataframe.ts:165


fromProperties()

static fromProperties(properties, rows): DataFrame

Creates a DataFrame from the specified properties with the specified row count.

Parameters

ParameterTypeDefault value
propertiesProperty[]undefined
rowsnumber0

Returns

DataFrame

Source

src/dataframe.ts:148