where_in

The where_in 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

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

Syntax

Parameters

ParameterTypeDescription
filter_tableTable

The table containing the set of values to filter on.

colsUnion[str, list[str]]

A list of columns (as Strings) to match between the two tables.

  • "X" will match on the same column name.
  • "X = Y" will match when the columns have different names, with X being the source table column and Y being the filter table column.

Matches are defined the same as the set inclusion operator (in).

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.

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.