Loading...

vastorbit.VastColumn.value_counts

VastColumn.value_counts(k: int = 30) TableSample

This function returns the k most frequently occurring elements in a column, along with information about how often they occur. Additionally, it provides various statistical details to give you a comprehensive view of the data distribution.

Parameters:

k (int, optional) – Number of most occurent elements to return.

Returns:

result.

Return type:

TableSample

Examples

For this example, we will use the following dataset:

import vastorbit as vo

data = vo.VastFrame(
    {
        "x": [1, 2, 4, 9, 10, 15, 20, 22],
        "y": [1, 2, 1, 2, 1, 1, 2, 1],
        "z": [10, 12, 2, 1, 9, 8, 1, 3],
    }
)

Now, let’s calculate the values and counts for a specific column.

data["x"].value_counts(k = 6)
value
name"x"
dtypeinteger
unique8.0
count8.0
11
Others1
91
151
21
41
221
Rows: 1-11 | Columns: 2

Note

All the calculations are pushed to the database.

Hint

For more precise control, please refer to the aggregate method.

See also

VastColumn.nunique() : Cardinality for a specific column.
VastFrame.duplicated() : Duplicated values for particular columns.