verticapy.vDataColumn.value_counts#
- vDataColumn.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#
- TableSample
result.
Examples#
For this example, we will use the following dataset:
import verticapy as vp data = vp.vDataFrame( { "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" dtype integer unique 8.0 count 8.0 9 1 10 1 1 1 4 1 2 1 15 1 Others 1 Note
All the calculations are pushed to the database.
Hint
For more precise control, please refer to the
aggregate
method.See also
vDataColumn.
nunique()
: Cardinality for a specific column.vDataFrame.
duplicated()
: Duplicated values for particular columns.