Login

Table

RESOURCE
Typing name :  RESOURCE.gws_core.Table Brick :  gws_core v Parent : 

2d excel like table

Main 2d table with named columns and named rows. It can also contains tags for each column and row.

It has a lot of transformers to manipulate the data.

It has a lot of chart views to visualize the data.

Table has more strict rules about row and column names than DataFrame :

  • Row names are converted to string and must be unique (if not, _1, _2, _3, ... are added to the name)
  • Column names are converted to string and must be unique (if not, _1, _2, _3, ... are added to the name)

If format_header_names is set to true, columns and row names are formatted (remove special characters, spaces, ...)

Views

rvResourceView.resource_view_spreadsheetTABULAR - view_as_table()Default view
View as a table
SMART INTERACTIVE PLOT - smart_view()
Generate an interactive plot using an AI (OpenAI).
VIEW RESOURCE - view_as_json()
View the complete resource as json

Functions




























































































__INIT__

Constructor, please do not overwrite this method, use the init method instead Leave the constructor without parameters.

Parameters:
dataUnion[pandas.core.frame.DataFrame, numpy.ndarray, list]
row_namesList
column_namesList
row_tagsList
column_tagsList
format_header_namesbool
ADD_COLUMN

Add a new column to the Dataframe.

Parameters:
namestr
dataUnion[list, pandas.core.series.Series]
indexint
ADD_COLUMN_TAG_BY_INDEX

Add a tag to a column at a given index

Parameters:
column_indexint int
keystr str
valuestr str
ADD_COLUMN_TAG_BY_NAME

Add a tag to a column by name

Parameters:
column_namestr str
keystr str
valuestr str
ADD_ROW

Add a row to the Dataframe.

Parameters:
namestr str
dataUnion[list, pandas.core.series.Series] list
indexint int, optional
ADD_ROW_TAG_BY_INDEX

Add a tag to a row at a given index

Parameters:
row_indexint int
keystr str
valuestr str
ADD_ROW_TAG_BY_NAME

Add a tag to a row by name

Parameters:
row_namestr str
keystr str
valuestr str
ADD_TECHNICAL_INFO

Add a technical information to the resource

Parameters:
technical_infoTechnicalInfo
CHECK_COLUMN_EXISTS

Checks if a column with the given name exists in the Table and raises an exception if it doesn't.

:raises Exception: If the column doesn't exist.

Parameters:
namestr str
case_sensitivebool bool
CHECK_RESOURCE

You can redefine this method to define custom logic to check this resource. If there is a problem with the resource, return a string that define the error, otherwise return None This method is called on output resources of a task. If there is an error returned, the task will be set to error and next proceses will not be run. It is also call when uploading a resource (usually for files or folder), if there is an error returned, the resource will not be uploaded

Return type:
Union[str, NoneType]
CHECK_ROW_EXISTS

Checks if a row with the given name exists in the Table and raises an exception if it doesn't.

:raises Exception: If the row doesn't exist.

Parameters:
namestr str
case_sensitivebool bool
CLONE

Clone the resource to create a new instance with a new id. It copies the RFields.

Return type:
ResourceType
COLUMN_EXISTS

Checks if a column with the given name exists in the Table.

Parameters:
namestr str
case_sensitivebool bool
Return type:
bool
COPY_COLUMN_TAGS_BY_INDEX

Copy column tags from source_table to self matching by index.

Parameters:
source_tableTable source table to copy tags from
from_indexint int, optional
to_indexint int, optional
COPY_COLUMN_TAGS_BY_NAME

Copy column tags from source_table to self matching by name.

Parameters:
source_tableTable source table to copy tags from
COPY_ROW_TAGS_BY_INDEX

Copy row tag from source_table to self matching by index

Parameters:
source_tableTable source table to copy tags from
from_indexint int, optional
to_indexint int, optional
COPY_ROW_TAGS_BY_NAME

Copy row tag from source_table to self matching by name

Parameters:
source_tableTable source table to copy tags from
CREATE_SUB_TABLE

Create a new table from a dataframe and a meta

Parameters:
dataframeDataFrame DataFrame
row_tagsList List[Dict[str, str]]
column_tagsList List[Dict[str, str]]
Return type:
Table
CREATE_SUB_TABLE_FILTERED_BY_COLUMNS

Create a sub Table based on a subset Dataframe of this original table filtered by columns It copies the tags of this table into the new table based on column names that matched between filtered_df and this dataframe.

Parameters:
filtered_dfDataFrame DataFrame
Return type:
Table
CREATE_SUB_TABLE_FILTERED_BY_ROWS

Create a sub Table based on a subset Dataframe of this original table filtered by rows. It copies the tags of this table into the new table based on row names that matched between filtered_df and this dataframe.

Parameters:
filtered_dfDataFrame DataFrame
Return type:
Table
EQUALS

Check if the table is equal to another table. It compares the data, row tags and column tags.

Parameters:
oobject object
Return type:
bool
EXTRACT_COLUMN_TAGS_TO_NEW_ROW

Create a new row and fill it with the values of the tag of each column.

                    If none, tag key is used as name, defaults to None
Parameters:
tag_keystr
new_row_namestr str, optional
EXTRACT_COLUMN_VALUES_TO_ROW_TAGS

Create a new tag for each row and fill it with the values of the provided column

                If none, column name is used as key, defaults to None
Parameters:
column_namestr str
new_tag_keystr str, optional
delete_columnbool bool, optional
EXTRACT_ROW_TAGS_TO_NEW_COLUMN

Create a new columns and fill it with the values of the tag of each row

                    If none, tag key is used as name, defaults to None
Parameters:
tag_keystr
new_column_namestr str, optional
EXTRACT_ROW_VALUES_TO_COLUMN_TAGS

Create a new tag for each column and fill it with the values of the row.

Parameters:
row_namestr str
new_tag_keystr str, optional
delete_rowbool bool, optional
FILTER_OUT_BY_COLUMN_NAMES

Filter out table columns matching a list of names, return a new table

Parameters:
filtersList List[DataframeFilterName]
Return type:
Table
FILTER_OUT_BY_ROW_NAMES

Filter out table rows matching a list of names, return a new table

Parameters:
filtersList List[DataframeFilterName]
Return type:
Table
FILTER_OUT_BY_TAGS

Filter out table rows or columns matching a list of tags and return a new table. The row or column that matches the tags are removed.

Example of search tags are:

  • tags = [ {"key1": "value1"} ] to filter out rows or columns having a tag {"key1": "value1"}
  • tags = [ {"key1": "value1", "key2": "value2"} ] to filter out rows or columns having tags {"key1": "value1"} AND {"key2": "value2"}
  • tags = [ {"key1": "value1"}, {"key2": "value2"} ] to filter out rows or columns having tags {"key1": "value1"} OR {"key2": "value2"}
  • tags = [ {"key1": "value1", "key2": "value2"}, {"key3": "value3"} ] to filter out rows or columns having tags ({"key1": "value1"} AND {"key2": "value2"}) OR {"key2": "value2"}
  • AND and OR logics can further be combined to perform complex selects
Parameters:
axisLiteral[0, 1, 'index', 'columns'] AxisType
tagsList List[dict]
Return type:
Table
GENERATE_NEW_COLUMN_NAME

Generates a column name that is unique in the Dataframe base on name. If the column name doesn't exist, return name, otherwise return name_1 or name_2, ... Only the name is returned, the column is not added to the Dataframe.

Parameters:
namestr str
Return type:
str
GET_AVAILABLE_COLUMN_TAGS

Get the available tags for each column.

Return type:
Dict
GET_AVAILABLE_ROW_TAGS

Get the available tags for each row.

Return type:
Dict
GET_CELL_VALUE_AT

Get the value of a cell at a given coordonate (row, column)

Parameters:
row_indexint int
column_indexint int
Return type:
Any
GET_COLUMN_AS_DATAFRAME

Returns a column with the given name as a DataFrame.

Parameters:
column_namestr str
skip_nan_empty bool
Return type:
DataFrame
GET_COLUMN_AS_LIST

Get a column as a list

Parameters:
column_namestr
skip_nan_empty
Return type:
list
GET_COLUMN_DATA

Returns the data of a column with the given name.

Parameters:
column_namestr str
skip_nanbool bool
Return type:
List
GET_COLUMN_INDEX_FROM_NAME

Get the index of a column from its name

Parameters:
column_namestr str
Return type:
int
GET_COLUMN_INFO

Get the info of a column by name

Parameters:
column_namestr str
Return type:
TableColumnInfo
GET_COLUMN_NAMES

Get the column names

Parameters:
from_indexint int, optional
to_indexint int, optional
Return type:
List
GET_COLUMN_NAMES_BY_INDEXES

Function to retrieve the column names based on column indexes

Parameters:
indexesList List[int]
Return type:
List
GET_COLUMN_TAGS

Get the tags of multiple columns by index

Parameters:
from_indexint int, optional
to_indexint int, optional
none_if_emptybool bool, optional
Return type:
List
GET_COLUMN_TAGS_BY_INDEX

Get the tags of a column at a given index

Parameters:
column_indexint int
Return type:
Dict
GET_COLUMN_TAGS_BY_NAME

Get the tags of a column by name

Parameters:
column_namestr str
Return type:
Dict
GET_COLUMN_TYPE

Get the type of a column

Parameters:
column_name_empty str
Return type:
TableColumnType
GET_COLUMNS_INFO

Get the info of multiple columns by index

Parameters:
from_indexint int, optional
to_indexint int, optional
Return type:
List
GET_DATA
Return type:
DataFrame
GET_DEFAULT_NAME

You can redefine this method to set a name of the resource. When saving the resource the name will be saved automatically This can be useful to distinguish this resource from another one or to search for the resource

Return type:
str
GET_ROW_DATA

Returns the data of a row with the given name.

Parameters:
row_namestr str
skip_nabool bool
Return type:
List
GET_ROW_INDEX_BY_NAME

Get the index of a row from its name. Raise an exception if the row doesn't exist

Parameters:
row_namestr str
Return type:
int
GET_ROW_INFO

Get the info of a row by name

Parameters:
row_namestr str
Return type:
TableHeaderInfo
GET_ROW_NAMES

Get the row names of the table by index

Parameters:
from_indexint int, optional
to_indexint int, optional
Return type:
List
GET_ROW_NAMES_BY_INDEXES

Function to retrieve the row names based on row indexes

Parameters:
indexesList List[int]
Return type:
List
GET_ROW_TAG_BY_NAME

Get the tags of a row by name

Parameters:
row_namestr str
Return type:
Dict
GET_ROW_TAGS

Get the tags of multiple rows by index

Parameters:
from_indexint int, optional
to_indexint int, optional
none_if_emptybool bool, optional
Return type:
List
GET_ROW_TAGS_BY_INDEX

Get the tags of a row at a given index

Parameters:
row_indexint int
Return type:
Dict
GET_ROWS_INFO

Get the info of multiple rows by index

Parameters:
from_indexint int, optional
to_indexint int, optional
Return type:
List
GET_TAGS

Get the tags of a given axis

Parameters:
axisLiteral[0, 1, 'index', 'columns'] AxisType
Return type:
List
GET_TECHNICAL_INFO

Get the technical information of the resource

Parameters:
keystr
Return type:
TechnicalInfo
INFER_OBJECTS

Call infer_objects on the underlying dataframe, it modifies the table dataframe.

Return type:
Table
INIT

This can be overwritten to perform custom initialization of the resource. This method is called just after the init (constructor) of the resource. The default values of RFields are set before this method is called.

REMOVE_COLUMN

Remove a column from the Dataframe.

Parameters:
column_namestr str
REMOVE_ROW

Remove a row from the Dataframe.

Parameters:
row_namestr str
ROW_EXISTS

Checks if a row with the given name exists in the Table.

Parameters:
namestr str
case_sensitivebool bool
Return type:
bool
SELECT_BY_COLUMN_INDEXES

Select table columns matching a list of indexes, return a new table

Parameters:
indexesList List[int]
Return type:
Table
SELECT_BY_COLUMN_NAMES

Select table columns matching a list of names, return a new table

Parameters:
filtersList List[DataframeFilterName]
Return type:
Table
SELECT_BY_COLUMN_TAGS

Select table columns matching a list of tags

Example of search tags are:

  • tags = [ {"key1": "value1"} ] to select columns having a tag {"key1": "value1"}
  • tags = [ {"key1": "value1", "key2": "value2"} ] to select columns having tags {"key1": "value1"} AND {"key2": "value2"}
  • tags = [ {"key1": "value1"}, {"key2": "value2"} ] to select columns having tags {"key1": "value1"} OR {"key2": "value2"}
  • tags = [ {"key1": "value1", "key2": "value2"}, {"key3": "value3"} ] to select columns having tags ({"key1": "value1"} AND {"key2": "value2"}) OR {"key2": "value2"}
  • AND and OR logics can further be combined to perform complex selects
Parameters:
tagsList List[dict]
Return type:
Table
SELECT_BY_COORDS

Create a new table from coords. It does not includes the to_row_id and to_column_id

Parameters:
from_row_idint int
from_column_idint int
to_row_idint int
to_column_idint int
Return type:
Table
SELECT_BY_ROW_INDEXES

Select table rows matching a list of indexes, return a new table

Parameters:
indexesList List[int]
Return type:
Table
SELECT_BY_ROW_NAMES

Select table rows matching a list of names, return a new table

Parameters:
filtersList List[DataframeFilterName]
Return type:
Table
SELECT_BY_ROW_TAGS

Select table rows matching a list of tags

Example of search tags are:

  • tags = [ {"key1": "value1"} ] to select rows having a tag {"key1": "value1"}
  • tags = [ {"key1": "value1", "key2": "value2"} ] to select rows having tags {"key1": "value1"} AND {"key2": "value2"}
  • tags = [ {"key1": "value1"}, {"key2": "value2"} ] to select rows having tags {"key1": "value1"} OR {"key2": "value2"}
  • tags = [ {"key1": "value1", "key2": "value2"}, {"key3": "value3"} ] to select rows having tags ({"key1": "value1"} AND {"key2": "value2"}) OR {"key2": "value2"}
  • AND and OR logics can further be combined to perform complex selects
Parameters:
tagsList List[dict]
Return type:
Table
SELECT_BY_TAGS

Select table rows or columns matching a list of tags and return a new table

Example of search tags are:

  • tags = [ {"key1": "value1"} ] to select rows or columns having a tag {"key1": "value1"}
  • tags = [ {"key1": "value1", "key2": "value2"} ] to select rows or columns having tags {"key1": "value1"} AND {"key2": "value2"}
  • tags = [ {"key1": "value1"}, {"key2": "value2"} ] to select rows or columns having tags {"key1": "value1"} OR {"key2": "value2"}
  • tags = [ {"key1": "value1", "key2": "value2"}, {"key3": "value3"} ] to select rows or columns having tags ({"key1": "value1"} AND {"key2": "value2"}) OR {"key2": "value2"}
  • AND and OR logics can further be combined to perform complex selects
Parameters:
axisLiteral[0, 1, 'index', 'columns'] AxisType
tagsList List[dict]
Return type:
Table
SELECT_NUMERIC_COLUMNS

Select only numeric columns, return a new table

            if drop_na = 'any', then drop columns where any values are nan (similar to `DataFrame.drop_na(how=all|any)`)
Parameters:
drop_naLiteral['all', 'any'] Literal['all', 'any']
Return type:
Table
SET_ALL_COLUMN_NAMES

Set the names of all columns

Parameters:
column_namesList list
SET_ALL_COLUMN_TAGS

Set the tags of all columns, the length of the list must be equal to the number of columns

Parameters:
tagsList List[Dict[str, str]]
SET_ALL_ROW_NAMES

Set the names of all rows

Parameters:
row_namesList list
SET_ALL_ROW_TAGS

Set the tags of all rows, the length of the list must be equal to the number of rows

Parameters:
tagsList List[Dict[str, str]]
SET_CELL_VALUE_AT

Set the value of a cell at a given coordonate (row, column)

Parameters:
row_indexint int
column_indexint int
valueAny Any
SET_COLUMN_NAME

Set the name of a column at a given index

Parameters:
current_namestr str
new_namestr str
SET_COLUMN_TAGS_BY_INDEX

Set the tags of a column at a given index

Parameters:
column_indexint int
tagsDict Dict[str, str]
SET_COLUMN_TAGS_BY_NAME

Set the tags of a column by name

Parameters:
column_namestr str
tagsDict Dict[str, str]
SET_COMMENTS
Parameters:
commentsstr
SET_ROW_NAME

Update the name of a row

Parameters:
current_nameAny str
new_namestr str
SET_ROW_TAGS_BY_INDEX

Set the tags of a row at a given index

Parameters:
row_indexint int
tagsDict Dict[str, str]
SET_ROW_TAGS_BY_NAME

Set the tags of a row by name

Parameters:
row_namestr str
tagsDict Dict[str, str]
TAIL

Returns the last n rows for the columns ant targets.

Parameters:
nrows_empty int
Return type:
DataFrame
TO_CSV

Returns the table as a csv string.

Return type:
str
TO_DATAFRAME

Returns the table as a pandas dataframe.

Return type:
DataFrame
TO_JSON

Returns the table as a json string.

Return type:
dict
TO_LIST

Returns the table as a list of lists.

Return type:
List
TO_NUMPY

Returns the table as a numpy array.

Return type:
ndarray
TRANSPOSE

Transpose the table, it returnes a new Table, the original table is not modified.

Parameters:
infer_objectsbool
Return type:
Table