select_distinct

The select_distinct method creates a new table containing all of the unique values for a set of key columns.

When the select_distinct method is used on multiple columns, it looks for distinct sets of values in the selected columns.

Syntax

select_distinct(formulas: Union[str, Sequence[str]]) -> Table

Parameters

ParameterTypeDescription
formulasUnion[str, Sequence[str]]

Key columns.

Returns

A new table containing all of the unique values for a set of key columns.

Examples

from deephaven import new_table
from deephaven.column import string_col, int_col

source = new_table(
    [
        string_col("A", ["apple", "apple", "orange", "orange", "plum", "grape"]),
        int_col("B", [1, 1, 2, 2, 3, 3]),
    ]
)

result = source.select_distinct(formulas=["A"])
from deephaven import new_table
from deephaven.column import string_col, int_col

source = new_table(
    [
        string_col("A", ["apple", "apple", "orange", "orange", "plum", "grape"]),
        int_col("B", [1, 1, 2, 2, 3, 3]),
    ]
)

result = source.select_distinct(formulas=["A", "B"])