Skip to main content

whereIn

The whereIn method returns a new table containing rows from the source table, where the rows match values in the filter table. The filter is updated whenever either table changes.

note

whereIn is not appropriate for all situations. Its purpose is to enable more efficient filtering for an infrequently changing filter table.

Syntax#

table.whereIn(filterTable, columnNames...)

Parameters#

ParameterTypeDescription
filterTabletable

The table containing the set of values to filter on.

columnNamesString...

The columns to match between the two tables.

  • "X" will match on the same column name. Equivalent to "X = X".
  • "X = Y" will match when the columns have different names.

Returns#

A new table containing rows from the source table, where the rows match values in the filter table. The filter is updated whenever either table changes.

Examples#

The following example creates a table containing only the colors present in the filter table.

from deephaven.TableTools import newTable, stringCol, intCol, doubleColfrom deephaven.conversion_utils import NULL_INT
source = newTable(    stringCol("Letter", "A", "C", "F", "B", "E", "D", "A"),    intCol("Number", NULL_INT, 2, 1, NULL_INT, 4, 5, 3),    stringCol("Color", "red", "blue", "orange", "purple", "yellow", "pink", "blue"),    intCol("Code", 12, 13, 11, NULL_INT, 16, 14, NULL_INT),)
filter = newTable(    stringCol("Colors", "blue", "red", "purple", "white"))
result = source.whereIn(filter, "Color = Colors")

The following example creates a table containing only the colors and codes present in the filter table. When using multiple matches, the resulting table will include only values that are in both matches. In this example, only one row matches both color AND codes. This results in a new table that has one matching value.

from deephaven.TableTools import newTable, stringCol, intCol, doubleColfrom deephaven.conversion_utils import NULL_INT
source = newTable(    stringCol("Letter", "A", "C", "F", "B", "E", "D", "A"),    intCol("Number", NULL_INT, 2, 1, NULL_INT, 4, 5, 3),    stringCol("Color", "red", "blue", "orange", "purple", "yellow", "pink", "blue"),    intCol("Code", 12, 13, 11, 10, 16, 14, NULL_INT),)
filter = newTable(    stringCol("Colors", "blue", "red", "purple", "white"),    intCol("Codes", 10, 12, 14, 16))
result = source.whereIn(filter, "Color = Colors", "Code = Codes")

Related documentation#