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
| Parameter | Type |
|---|---|
dart | any |
Returns
Source
src/dataframe/data-frame.ts:58
Properties
| Property | Modifier | Type |
|---|---|---|
_dialogs | private | undefined | DataFrameDialogHelper |
_meta | public | undefined | DataFrameMetaHelper |
_plot | private | undefined | DataFramePlotHelper |
columns | public | ColumnList |
dart | readonly | any |
filter | public | BitSet |
rows | public | RowList |
tags | public | any |
temp | public | any |
Accessors
currentCell
getcurrentCell():Cell
Current cell. Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements
setcurrentCell(cell):void
Current cell. Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements
Parameters
| Parameter | Type |
|---|---|
cell | Cell |
Returns
Source
src/dataframe/data-frame.ts:308
currentCol
getcurrentCol():Column<any,any>
Current column. Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements
setcurrentCol(col):void
Current column. Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements
Parameters
| Parameter | Type |
|---|---|
col | Column<any, any> |
Returns
Column<any, any>
Source
src/dataframe/data-frame.ts:296
currentRow
getcurrentRow():Row
Current row. Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements
setcurrentRow(row):void
Parameters
| Parameter | Type |
|---|---|
row | Row |
Returns
Source
src/dataframe/data-frame.ts:283
currentRowIdx
getcurrentRowIdx():number
Index of the current row.
setcurrentRowIdx(idx):void
Parameters
| Parameter | Type |
|---|---|
idx | number |
Returns
number
Source
src/dataframe/data-frame.ts:287
dialogs
getdialogs():DataFrameDialogHelper
Returns
Source
src/dataframe/data-frame.ts:149
id
getid():string
Id of the dataframe.
setid(id):void
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
string
Source
src/dataframe/data-frame.ts:482
meta
getmeta():DataFrameMetaHelper
A helper to conveniently access certain metadata properties stored in tags
Returns
Source
src/dataframe/data-frame.ts:136
mouseOverRowIdx
getmouseOverRowIdx():number
Index of the mouse-over row.
setmouseOverRowIdx(idx):void
Parameters
| Parameter | Type |
|---|---|
idx | number |
Returns
number
Source
src/dataframe/data-frame.ts:291
name
getname():string
Name of the dataframe.
setname(s):void
Parameters
| Parameter | Type |
|---|---|
s | string |
Returns
string
Source
src/dataframe/data-frame.ts:166
onColumnNameChanged
getonColumnNameChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:427
onColumnSelectionChanged
getonColumnSelectionChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:430
onColumnsAdded
getonColumnsAdded():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:436
onColumnsChanged
getonColumnsChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:433
onColumnsRemoved
getonColumnsRemoved():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:439
onCurrentCellChanged
getonCurrentCellChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:415
onCurrentColChanged
getonCurrentColChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:409
onCurrentRowChanged
getonCurrentRowChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/current-elements
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:403
onDataChanged
getonDataChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:460
onFilterChanged
getonFilterChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:469
onMetadataChanged
getonMetadataChanged():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/data-frame.ts:424
onMouseOverColChanged
getonMouseOverColChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:412
onMouseOverRowChanged
getonMouseOverRowChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:406
onMouseOverRowGroupChanged
getonMouseOverRowGroupChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:418
onNameChanged
getonNameChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:421
onRowsAdded
getonRowsAdded():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:442
onRowsFiltered
getonRowsFiltered():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:448
onRowsFiltering
getonRowsFiltering():Observable<any>
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:451
onRowsRemoved
getonRowsRemoved():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:445
onSelectionChanged
getonSelectionChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:466
onSemanticTypeDetected
getonSemanticTypeDetected():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/advanced/semantic-type-detection
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:457
onSemanticTypeDetecting
getonSemanticTypeDetecting():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/advanced/semantic-type-detection
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:454
onValuesChanged
getonValuesChanged():Observable<any>
Sample: https://public.datagrok.ai/js/samples/data-frame/events/events
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:400
plot
getplot():DataFramePlotHelper
A helper for creating plots for this dataframe
Returns
Source
src/dataframe/data-frame.ts:143
rowCount
getrowCount():number
Returns number of rows in the table.
Returns
number
Source
src/dataframe/data-frame.ts:156
selection
getselection():BitSet
Returns a BitSet with selected rows.
Returns
Source
src/dataframe/data-frame.ts:161
Methods
_event()
_event(
event):Observable<any>
Parameters
| Parameter | Type |
|---|---|
event | string |
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:391
_exportReopen()
_exportReopen():
DataFrame
Returns
Source
src/dataframe/data-frame.ts:498
append()
append(
t2,inPlace,columnsToAppend):DataFrame
Appends two tables ('union' in SQL).
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
t2 | DataFrame | undefined | |
inPlace | boolean | false | whether to create a new table, or modify 'this' one. |
columnsToAppend | null | string[] | null |
Returns
Source
src/dataframe/data-frame.ts:383
appendMerge()
appendMerge(
t):void
Parameters
| Parameter | Type |
|---|---|
t | DataFrame |
Returns
void
Source
src/dataframe/data-frame.ts:387
cell()
cell(
idx,name):Cell
Returns a Cell with the specified row and column.
Parameters
| Parameter | Type | Description |
|---|---|---|
idx | number | Row index. |
name | string | Column name. |
Returns
Source
src/dataframe/data-frame.ts:223
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
column | string | Column<any, any> | undefined | |
newType | "string" | "bigint" | "object" | "int" | "double" | "bool" | "byte_array" | "datetime" | "qnum" | "dataframe" | undefined | |
format | null | string | null | number format |
Returns
Column<any, any>
See
Source
src/dataframe/data-frame.ts:324
clone()
clone(
rowMask,columnIds,saveSelection):DataFrame
Creates a new dataframe from the specified row mask and a list of columns.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
rowMask | null | BitSet | null | Rows to include. |
columnIds | null | string[] | null | Columns to include. |
saveSelection | boolean | false | Whether selection should be saved. |
Returns
Source
src/dataframe/data-frame.ts:277
col()
col(
nameOrIndex):null|Column<any,any>
Returns a Column with the specified name.
Parameters
| Parameter | Type | Description |
|---|---|---|
nameOrIndex | string | number | Column name. |
Returns
null | Column<any, any>
Source
src/dataframe/data-frame.ts:210
fireValuesChanged()
fireValuesChanged():
void
Returns
void
Source
src/dataframe/data-frame.ts:471
get()
get(
name,idx):any
Returns idx-th value of the specified columns.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Column name. |
idx | number | Row index. |
Returns
any
Source
src/dataframe/data-frame.ts:195
getCol()
getCol(
name):Column<any,any>
Same as col, but throws Error if column is not found
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Column name. |
Returns
Column<any, any>
Source
src/dataframe/data-frame.ts:230
getDensity()
getDensity(
xBins,yBins,xColName,yColName):Int32Array
Parameters
| Parameter | Type |
|---|---|
xBins | number |
yBins | number |
xColName | string |
yColName | string |
Returns
Int32Array
Source
src/dataframe/data-frame.ts:490
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
sortByColumnIds | ColumnId[] | undefined | Collection of [Column]s to use as keys for sorting. |
sortOrders | null | boolean[] | null | List of sort orders for [sortByCols]. True == ascending. |
rowMask | null | BitSet | null | Mask of the rows to sort. Result array will contain [rowIndexes.length] elements. |
Returns
Int32Array
Source
src/dataframe/data-frame.ts:337
getTableInfo()
getTableInfo():
TableInfo
Returns
Source
src/dataframe/data-frame.ts:494
getTag()
getTag(
tag):null|string
Returns the value of the specified tag, or null if it does not exist.
Parameters
| Parameter | Type |
|---|---|
tag | string |
Returns
null | string
Source
src/dataframe/data-frame.ts:171
groupBy()
groupBy(
columnNames):GroupByBuilder
Begins building a query, using the specified columns as keys.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
columnNames | string[] | [] | Names of the columns to be used as keys. |
Returns
Source
src/dataframe/data-frame.ts:345
join()
join(
t2,keyColumns1,keyColumns2,valueColumns1,valueColumns2,joinType,inPlace):DataFrame
Merges two tables by the specified key columns.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
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
src/dataframe/data-frame.ts:372
onEvent()
onEvent(
event):Observable<any>
Parameters
| Parameter | Type |
|---|---|
event | string |
Returns
Observable<any>
Source
src/dataframe/data-frame.ts:395
row()
row(
rowIndex):Row
Returns i-th row. NOTE: Do not use in performance-critical paths, consider accessing values via the Column instance.
Parameters
| Parameter | Type |
|---|---|
rowIndex | number |
Returns
Source
src/dataframe/data-frame.ts:188
set()
set(
name,idx,value):void
Sets idx-th value of the specified columns.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Column name. |
idx | number | Row index. |
value | any | Value. |
Returns
void
Source
src/dataframe/data-frame.ts:203
setTag()
setTag(
tag,value):DataFrame
Sets a tag to the specified value.
Parameters
| Parameter | Type | Description |
|---|---|---|
tag | string | Key. |
value | string | Value. |
Returns
Source
src/dataframe/data-frame.ts:178
toByteArray()
toByteArray():
Uint8Array
Exports dataframe to binary
Returns
Uint8Array
Source
src/dataframe/data-frame.ts:269
toCsv()
toCsv(
options?,grid?):string
Exports the content to comma-separated-values format.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | CsvExportOptions | options for the export |
grid? | Grid | if specified, takes visible columns, column and row order from the grid. |
Returns
string
Source
src/dataframe/data-frame.ts:241
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
| Parameter | Type | Description |
|---|---|---|
options? | CsvExportOptions | options for the export |
grid? | Grid | if specified, takes visible columns, column and row order from the grid. |
Returns
Promise<string>
Source
src/dataframe/data-frame.ts:250
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/data-frame.ts:257
toString()
toString():
string
Returns
string
Source
src/dataframe/data-frame.ts:476
unpivot()
unpivot(
copyColumnNames,mergeColumnNames,categoryColumnName,valueColumnName):DataFrame
Unpivots the table (converts from 'wide' representation with many columns to 'tall and skinny').
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
copyColumnNames | string[] | undefined | columns to copy |
mergeColumnNames | string[] | 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. |
categoryColumnName | string | 'Category' | - |
valueColumnName | string | 'Value' | - |
Returns
Source
src/dataframe/data-frame.ts:355
create()
staticcreate(rowCount,name?):DataFrame
Creates a DataFrame with the specified number of rows and no columns.
Parameters
| Parameter | Type | Default value |
|---|---|---|
rowCount | number | 0 |
name? | string | undefined |
Returns
Source
src/dataframe/data-frame.ts:68
fromByteArray()
staticfromByteArray(byteArray):DataFrame
Parameters
| Parameter | Type |
|---|---|
byteArray | Uint8Array |
Returns
Source
src/dataframe/data-frame.ts:75
fromColumns()
staticfromColumns(columns):DataFrame
Creates a DataFrame from the specified columns. All columns should be of the same length.
Parameters
| Parameter | Type |
|---|---|
columns | Column<any, any>[] |
Returns
Source
src/dataframe/data-frame.ts:80
fromCsv()
staticfromCsv(csv,options?):DataFrame
Constructs DataFrame from a comma-separated values string
Parameters
| Parameter | Type | Description |
|---|---|---|
csv | string | The content of the comma-separated values file. https://dev.datagrok.ai/script/samples/javascript/data-frame/construction/create-from-csv |
options? | CsvImportOptions | - |
Returns
Source
src/dataframe/data-frame.ts:123
fromJson()
staticfromJson(json):DataFrame
Constructs DataFrame from the specified JSON string.
Parameters
| Parameter | Type | Description |
|---|---|---|
json | string | JSON document. https://dev.datagrok.ai/script/samples/javascript/data-frame/construction/create-from-json |
Returns
Source
src/dataframe/data-frame.ts:131
fromObjects()
staticfromObjects(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
| Parameter | Type | Description |
|---|---|---|
list | object[] | List of objects. https://dev.datagrok.ai/script/samples/javascript/data-frame/construction/create-from-objects |
Returns
undefined | DataFrame
Source
src/dataframe/data-frame.ts:102
fromProperties()
staticfromProperties(properties,rows):DataFrame
Creates a DataFrame from the specified properties with the specified row count.
Parameters
| Parameter | Type | Default value |
|---|---|---|
properties | Property[] | undefined |
rows | number | 0 |