Select rows in Table with 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.SelectTableRowsFromTable[source]

Select rows in Table by using an additional Table with predefined comparison relations. :Ref. nodes: Select rows in Table and Select rows in Tables

Inputs:
port1 : table

Table with 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.

port2 : table

Input Table

Outputs:
port1 : table

Table with rows in Selection

Configuration:
Column with column names

Select column in the selection Table that includes listed column names.

Column with comparison operators

Select column in the selection Table that includes listed comparison operators.

Column with constraint values

Select column in the selection Table that includes listed constraint values.

Reduction:

If there are multiple selection criteria, do ALL of them need to be fulfilled for a data row to be selected, or is it enough that ANY single criterion is fulfilled?