Loading...

verticapy.vDataFrame.var#

vDataFrame.var(columns: str | list[str] | None = None, **agg_kwargs) TableSample#

Aggregates the vDataFrame using VAR aggregation (Variance), providing insights into the spread or variability of data for the selected columns. The variance is a measure of how much individual data points deviate from the mean, helping to assess data consistency and variation.

Parameters#

columns: SQLColumns, optional

List of the vDataColumns names. If empty, all numerical vDataColumns are used.

**agg_kwargs

Any optional parameter to pass to the Aggregate function.

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 variance for specific columns.

data.var(
    columns = ["x", "y", "z"],
)
variance
"x"64.2678571428571
"y"0.267857142857143
"z"19.9285714285714

Note

All the calculations are pushed to the database.

Hint

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

See also

vDataColumn.kurtosis() : Kurtosis for a specific column.
vDataColumn.skewness() : Skewness for a specific column.
vDataFrame.std() : Standard Deviation for particular columns.