Login
Back to bricks list
Introduction Version

Feature table

RESOURCE
Typing name :  RESOURCE.gws_ubiome.FeatureTable Brick :  gws_ubiome
Parent :
Table

FeatureTable class

Views

TABULARDefault view
View as a table
SMART INTERACTIVE PLOT
Generate an interactive plot using an AI (OpenAI).
VIEW RESOURCE
View the complete resource as json
FEATURE STACKED BARPLOT
Feature stacked barplots

Functions

__INIT__

Create a new Table

                                - convert to string
                                - remove leading and trailing whitespaces
                                - rename duplicates by adding _1, _2, _3, ... at the end of the name
                               If true, the previous rules apply plus :
                                - replace ' ', '-', '.' with underscores
                                - remove all other special characters
                                - remove all accents
Parameters:
NameTypeDefault valueDescription
dataUnion[pandas.core.frame.DataFrame, numpy.ndarray, list] None Data use to initilialize the table, defaults to none union[dataframe, np.ndarray, list], optional
row_namesList None Set the row names for the table. must be the same size as the number of rows, defaults to none [str], optional
column_namesList None Set the column names for the table. must be the same size as the number of columns, defaults to none [str], optional
row_tagsList None Set the row tags for the table. must be the same size as the number of rows, defaults to none [dict[str, str]], optional
column_tagsList None Set the column tags for the table. must be the same size as the number of columns, defaults to none [dict[str, str]], optional
strict_format_header_namesbool False If false, the following rules are applied to headers (columns and rows) names: , optional
ADD_COLUMN

Add a new column to the Dataframe.

Parameters:
NameTypeDefault valueDescription
namestr Name of the column
dataUnion[list, pandas.core.series.Series] None Data for the column, must be the same length as other colums list
indexint None Index for the column, if none, the column is append to the end, defaults to none , optional
ADD_COLUMN_TAG_BY_INDEX

Add a tag to a column at a given index

Parameters:
NameTypeDefault valueDescription
column_indexint Index of the column
keystr Key of the tag
valuestr Value of the tag
ADD_COLUMN_TAG_BY_NAME

Add a tag to a column by name

Parameters:
NameTypeDefault valueDescription
column_namestr Name of the column
keystr Key of the tag
valuestr Value of the tag
ADD_ROW

Add a row to the Dataframe.

Parameters:
NameTypeDefault valueDescription
namestr Name of the row
dataUnion[list, pandas.core.series.Series] None Data of the row list
indexint None Index of the row, if none, the row is append to the end, defaults to none , optional
ADD_ROW_TAG_BY_INDEX

Add a tag to a row at a given index

Parameters:
NameTypeDefault valueDescription
row_indexint Index of the row
keystr Key of the tag
valuestr Value of the tag
ADD_ROW_TAG_BY_NAME

Add a tag to a row by name

Parameters:
NameTypeDefault valueDescription
row_namestr Name of the row
keystr Key of the tag
valuestr Value of the tag
ADD_TECHNICAL_INFO

Add technical information on the resource. Technical info are useful to set additional information on the resource.

Parameters:
NameTypeDefault valueDescription
technical_infoTechnicalInfo Technical information to add (key, value)
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:
NameTypeDefault valueDescription
namestr The name of the column to check.
case_sensitivebool True Whether the check should be case sensitive. defaults to true.
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:
NameTypeDefault valueDescription
namestr The name of the row to check.
case_sensitivebool True Whether the check should be case sensitive. defaults to true.
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:
NameTypeDefault valueDescription
namestr The name of the column to check.
case_sensitivebool True Whether the check should be case sensitive. defaults to true.
Return type:
bool
COPY_COLUMN_TAGS_BY_INDEX

Copy column tags from source_table to self matching by index.

Parameters:
NameTypeDefault valueDescription
source_tableTable Source table to copy tags from
from_indexint None Start index of the columns to copy, defaults to none , optional
to_indexint None End index of the columns to copy, defaults to none , optional
COPY_COLUMN_TAGS_BY_NAME

Copy column tags from source_table to self matching by name.

Parameters:
NameTypeDefault valueDescription
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:
NameTypeDefault valueDescription
source_tableTable Source table to copy tags from
from_indexint None Start index of the rows to copy, defaults to none , optional
to_indexint None End index of the rows to copy, defaults to none , optional
COPY_ROW_TAGS_BY_NAME

Copy row tag from source_table to self matching by name

Parameters:
NameTypeDefault valueDescription
source_tableTable Source table to copy tags from
CREATE_SUB_TABLE

Create a new table from a dataframe and a meta

Parameters:
NameTypeDefault valueDescription
dataframeDataFrame The dataframe
row_tagsList The list of row tags [dict[str, str]]
column_tagsList The list of column tags [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:
NameTypeDefault valueDescription
filtered_dfDataFrame The filtered 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:
NameTypeDefault valueDescription
filtered_dfDataFrame The filtered dataframe
Return type:
Table
EQUALS

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

Parameters:
NameTypeDefault valueDescription
oobject The other table
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:
NameTypeDefault valueDescription
tag_keystr
new_row_namestr None Name of the new row that will contains tag values. , 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:
NameTypeDefault valueDescription
column_namestr Name of the column to extract
new_tag_keystr None Key of the new tag that will contains column values. , optional
delete_columnbool False If true, delete the column after the extraction, defaults to false , 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:
NameTypeDefault valueDescription
tag_keystr
new_column_namestr None Name of the new column that will contains tag values. , optional
EXTRACT_ROW_VALUES_TO_COLUMN_TAGS

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

Parameters:
NameTypeDefault valueDescription
row_namestr Name of the row to extract values from
new_tag_keystr None Key of the new tag that will contains row values. if none, row name is used as key, defaults to none , optional
delete_rowbool False If true, delete the row after the extraction, defaults to false , optional
FILTER_OUT_BY_COLUMN_NAMES

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

Parameters:
NameTypeDefault valueDescription
filtersList The list of names [dataframefiltername]
Return type:
Table
FILTER_OUT_BY_ROW_NAMES

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

Parameters:
NameTypeDefault valueDescription
filtersList The list of names [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:
NameTypeDefault valueDescription
axisLiteral[0, 1, 'index', 'columns'] Axis to filter out the tags axistype
tagsList The of tags [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:
NameTypeDefault valueDescription
namestr Name of the column
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:
NameTypeDefault valueDescription
row_indexint Index of the row
column_indexint Index of the column
Return type:
Any
GET_COLUMN_AS_DATAFRAME

Returns a column with the given name as a DataFrame.

Parameters:
NameTypeDefault valueDescription
column_namestr The name of the column.
skip_nanbool False Whether to skip nan values. defaults to false.
Return type:
DataFrame
GET_COLUMN_DATA

Returns the data of a column with the given name.

Parameters:
NameTypeDefault valueDescription
column_namestr The name of the column.
skip_nanbool False Whether to skip nan values. defaults to false.
Return type:
List
GET_COLUMN_INDEX_FROM_NAME

Get the index of a column from its name

Parameters:
NameTypeDefault valueDescription
column_namestr Name of the column
Return type:
int
GET_COLUMN_INFO

Get the info of a column by name

Parameters:
NameTypeDefault valueDescription
column_namestr Name of the column
Return type:
TableColumnInfo
GET_COLUMN_NAMES

Get the column names

Parameters:
NameTypeDefault valueDescription
from_indexint None Start index of the columns to retrieve, defaults to none , optional
to_indexint None End index of the columns to retrieve, defaults to none , optional
Return type:
List
GET_COLUMN_NAMES_BY_INDEXES

Function to retrieve the column names based on column indexes

Parameters:
NameTypeDefault valueDescription
indexesList List of column indexes [int]
Return type:
List
GET_COLUMN_TAGS

Get the tags of multiple columns by index

Parameters:
NameTypeDefault valueDescription
from_indexint None Start index of the columns to retrieve, defaults to none , optional
to_indexint None End index of the columns to retrieve, to_index is included, defaults to none , optional
none_if_emptybool False If true, return none if no tags are found, defaults to false , optional
Return type:
List
GET_COLUMN_TAGS_BY_INDEX

Get the tags of a column at a given index

Parameters:
NameTypeDefault valueDescription
column_indexint Index of the column
Return type:
Dict
GET_COLUMN_TAGS_BY_NAME

Get the tags of a column by name

Parameters:
NameTypeDefault valueDescription
column_namestr Name of the column
Return type:
Dict
GET_COLUMN_TYPE

Get the type of a column

Parameters:
NameTypeDefault valueDescription
column_nameAny Name of the column str
Return type:
TableColumnType
GET_COLUMNS_INFO

Get the info of multiple columns by index

Parameters:
NameTypeDefault valueDescription
from_indexint None Start index of the columns to retrieve, defaults to none , optional
to_indexint None End index of the columns to retrieve, defaults to none , 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:
NameTypeDefault valueDescription
row_namestr The name of the row.
skip_nabool False Whether to skip nan values. defaults to false.
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:
NameTypeDefault valueDescription
row_namestr Name of the row
Return type:
int
GET_ROW_INFO

Get the info of a row by name

Parameters:
NameTypeDefault valueDescription
row_namestr Name of the row
Return type:
TableHeaderInfo
GET_ROW_NAMES

Get the row names of the table by index

Parameters:
NameTypeDefault valueDescription
from_indexint None Start index of the rows to retrieve, defaults to none , optional
to_indexint None End index of the rows to retrieve, defaults to none , optional
Return type:
List
GET_ROW_NAMES_BY_INDEXES

Function to retrieve the row names based on row indexes

Parameters:
NameTypeDefault valueDescription
indexesList List of row indexes [int]
Return type:
List
GET_ROW_TAG_BY_NAME

Get the tags of a row by name

Parameters:
NameTypeDefault valueDescription
row_namestr Name of the row
Return type:
Dict
GET_ROW_TAGS

Get the tags of multiple rows by index

Parameters:
NameTypeDefault valueDescription
from_indexint None Start index of the rows to retrieve, defaults to none , optional
to_indexint None End index of the rows to retrieve, to_index is included, defaults to none , optional
none_if_emptybool False If true, return none if no tags are found, defaults to false , optional
Return type:
List
GET_ROW_TAGS_BY_INDEX

Get the tags of a row at a given index

Parameters:
NameTypeDefault valueDescription
row_indexint Index of the row
Return type:
Dict
GET_ROWS_INFO

Get the info of multiple rows by index

Parameters:
NameTypeDefault valueDescription
from_indexint None Start index of the rows to retrieve, defaults to none , optional
to_indexint None End index of the rows to retrieve, defaults to none , optional
Return type:
List
GET_TAGS

Get the tags of a given axis

Parameters:
NameTypeDefault valueDescription
axisLiteral[0, 1, 'index', 'columns'] Axis to retrieve the tags axistype
Return type:
List
GET_TECHNICAL_INFO

Get the technical information of the resource

Parameters:
NameTypeDefault valueDescription
keystr Key of the technical information
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:
NameTypeDefault valueDescription
column_namestr Name of the column
REMOVE_ROW

Remove a row from the Dataframe.

Parameters:
NameTypeDefault valueDescription
row_namestr Name of the row to remove
ROW_EXISTS

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

Parameters:
NameTypeDefault valueDescription
namestr The name of the row to check.
case_sensitivebool True Whether the check should be case sensitive. defaults to true.
Return type:
bool
SELECT_BY_COLUMN_INDEXES

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

Parameters:
NameTypeDefault valueDescription
indexesList The list of indexes [int]
Return type:
Table
SELECT_BY_COLUMN_NAMES

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

Parameters:
NameTypeDefault valueDescription
filtersList The list of names [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:
NameTypeDefault valueDescription
tagsList The of tags [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:
NameTypeDefault valueDescription
from_row_idint Start row index
from_column_idint Start column index
to_row_idint End row index
to_column_idint End column index
Return type:
Table
SELECT_BY_ROW_INDEXES

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

Parameters:
NameTypeDefault valueDescription
indexesList The list of indexes [int]
Return type:
Table
SELECT_BY_ROW_NAMES

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

Parameters:
NameTypeDefault valueDescription
filtersList The list of names [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:
NameTypeDefault valueDescription
tagsList The of tags [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:
NameTypeDefault valueDescription
axisLiteral[0, 1, 'index', 'columns'] Axis to select the tags axistype
tagsList The of tags [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:
NameTypeDefault valueDescription
drop_naLiteral['all', 'any'] all If drop_na = 'all', then drops columns where all values are nan (similar to `dataframe.drop_na(how=all|any)`) literal['all', 'any']
Return type:
Table
SET_ALL_COLUMN_NAMES

Set the names of all columns

Parameters:
NameTypeDefault valueDescription
column_namesList List of column names 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:
NameTypeDefault valueDescription
tagsList List of tags [dict[str, str]]
SET_ALL_ROW_NAMES

Set the names of all rows

Parameters:
NameTypeDefault valueDescription
row_namesList List of row names, must be the same length number of rows 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:
NameTypeDefault valueDescription
tagsList List of tags [dict[str, str]]
SET_CELL_VALUE_AT

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

Parameters:
NameTypeDefault valueDescription
row_indexint Index of the row
column_indexint Index of the column
valueAny Value to set
SET_COLUMN_NAME

Set the name of a column at a given index

Parameters:
NameTypeDefault valueDescription
current_namestr Current name of the column
new_namestr New name of the column
SET_COLUMN_TAGS_BY_INDEX

Set the tags of a column at a given index

Parameters:
NameTypeDefault valueDescription
column_indexint Index of the column
tagsDict Tags to set [str, str]
SET_COLUMN_TAGS_BY_NAME

Set the tags of a column by name

Parameters:
NameTypeDefault valueDescription
column_namestr Name of the column
tagsDict Tags to set [str, str]
SET_COMMENTS
Parameters:
NameTypeDefault valueDescription
commentsstr ''
SET_ROW_NAME

Update the name of a row

Parameters:
NameTypeDefault valueDescription
current_nameAny Current name of the row str
new_namestr New name of the row
SET_ROW_TAGS_BY_INDEX

Set the tags of a row at a given index

Parameters:
NameTypeDefault valueDescription
row_indexint Index of the row
tagsDict Tags to set [str, str]
SET_ROW_TAGS_BY_NAME

Set the tags of a row by name

Parameters:
NameTypeDefault valueDescription
row_namestr Name of the row
tagsDict Tags to set [str, str]
TAIL

Returns the last n rows for the columns ant targets.

Parameters:
NameTypeDefault valueDescription
nrowsint 5 Number of rows
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:
NameTypeDefault valueDescription
infer_objectsbool False
Return type:
Table