in
The in match filter returns rows that contain a match of one or more specified values.
Syntax
columnName in valueList
columnName- the column the filter will search for matching values.valueList- the set of values to match on. This supports:- a comma-separated list of values:
A in X, Y, Z. The filter will returntruefor all rows where the value in columnAis equal toX,Y, orZ. - a java array:
A in X. The filter will returntruefor all rows whereAis equal to at least one element of the java arrayX. - a
java.util.Collection:A in X. The filter will returntruefor all rows whereAis equal to at least one element of the collectionX. - all other types:
A in X. The filter will returntruefor all rows whereAis equal toX.
- a comma-separated list of values:
Examples
The following example returns rows where Color is in a comma-separated list of values.
from deephaven import new_table
from deephaven.column import string_col, int_col
from deephaven.constants import NULL_INT
source = new_table(
[
string_col("Letter", ["A", "C", "F", "B", "E", "D", "A"]),
int_col("Number", [NULL_INT, 2, 1, NULL_INT, 4, 5, 3]),
string_col(
"Color", ["red", "blue", "orange", "purple", "yellow", "pink", "blue"]
),
int_col("Code", [12, 14, 11, NULL_INT, 16, 14, NULL_INT]),
]
)
result = source.where(filters=["Color in `blue`, `orange`"])
The following example returns rows where Number is in an array of values.
from deephaven import new_table
from deephaven.column import string_col, int_col
from deephaven.constants import NULL_INT
array = [2, 4, 6]
source = new_table(
[
string_col("Letter", ["A", "C", "F", "B", "E", "D", "A"]),
int_col("Number", [NULL_INT, 2, 1, NULL_INT, 4, 5, 3]),
string_col(
"Color", ["red", "blue", "orange", "purple", "yellow", "pink", "blue"]
),
int_col("Code", [12, 14, 11, NULL_INT, 16, 14, NULL_INT]),
]
)
result = source.where(filters=["Number in array"])
The following example returns rows where Number is in an array of values or Code is in an array of values.
from deephaven import new_table
from deephaven.column import string_col, int_col
from deephaven.constants import NULL_INT
number_array = [2, 4, 6]
code_array = [10, 12, 14]
source = new_table(
[
string_col("Letter", ["A", "C", "F", "B", "E", "D", "A"]),
int_col("Number", [NULL_INT, 2, 1, NULL_INT, 4, 5, 3]),
string_col(
"Color", ["red", "blue", "orange", "purple", "yellow", "pink", "blue"]
),
int_col("Code", [12, 14, 11, NULL_INT, 16, 14, NULL_INT]),
]
)
result = source.where_one_of(filters=["Number in number_array", "Code in code_array"])
The following example returns rows where Color is in a collection of values.
from deephaven import new_table
from deephaven.column import string_col, int_col
from deephaven.constants import NULL_INT
my_list = ["pink", "purple", "blue"]
source = new_table(
[
string_col("Letter", ["A", "C", "F", "B", "E", "D", "A"]),
int_col("Number", [NULL_INT, 2, 1, NULL_INT, 4, 5, 3]),
string_col(
"Color", ["red", "blue", "orange", "purple", "yellow", "pink", "blue"]
),
int_col("Code", [12, 14, 11, NULL_INT, 16, 14, NULL_INT]),
]
)
result = source.where(filters=["Color in my_list"])