Select rows in Table

../../../../../_images/select_table_rows.svg

In the standard library there exist three nodes where rows in one or several Tables can be selected with help of defind constraint relations. The Tables in the outputs will have lesser or equal number of rows as the incoming Tables.

The rows to select are determined by constraint relations that are applied to one or many selected columns in the Table. The intersection of the results from the applied relations is used to filter the rows of the whole incoming Table.

The following operators are recognised by the node:
  • equal (==)
  • less than (<)
  • less than or equal (<=)
  • greater than (>)
  • greater than or equal (>=)
  • not equal (!=).

For two of the nodes, Select rows in Table and Select rows in Tables, the configuration GUI is used to set up a single constraint relation that can be applied to one or many columns of the incoming Table. The input Table has three columns that defines a set of comparison relations. Each row in the set will set up a comparison relation with a column name, a comparison operator and a constraint value.

A custom constraint can be set up using a lambda function. See https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions for a description of these.

The output Table has the result from the selection of rows. There will be lesser or equal number of rows compared to the input. The number of columns is the same.

In the third node, Select rows in Table with Table, the constraint relations are predefined in an additional incoming Table. Three columns in this Table includes column names, comparison operators and constraint values, respectively. The comparison operators that can be used are listed above and remember to use the string expressions, as an example use equal instead of ==.

class node_select_table_rows.SelectTableRows

Select rows in Tables by applying a comparison relation to a number of columns in the incoming Tables.

A custom filter function can be defined by writing a lambda function. The lambda function will be called once for each selected column with that column as a pandas.Series as argument. The lambda function should return an array-like object (e.g. numpy.ndarray or pandas.Series) with boolean dtype and as many items as there was in the argument.

See https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions for a description of lambda functions. Have a look at the Data type APIs to see what methods and attributes are available on the data type that you are working with.

Ref. nodes:

Select rows in Table and Select rows in Table with Table

Inputs:
Input : table

Input

Outputs:
Output : table

Output

Configuration:
Columns to filter

Select columns for comparison relation

Constraint must be satisfied in

Constraint must be satisfied in: Any selected column or All selected columns.

Relation

Select comparison operator for relation

Filter constraint

Specify constraint value for comparison relation

Use custom filter

Select to use custom filter

Custom filter

Write a custom filter as a Python lambda function

Preview rows

Rows to display