KitDocumentation

ColumnVariance

Computes the variance of one or more columns. Furthermore, can compute the variance while being grouped by another column or category, perform a rolling variance or sliding window variance, can compute the variance for only rows that meet a condition, and can add the result to the dataframe as a new column

Options

columns: Specifies columns to calculate variance
where: Specifies a condition for the calculation
group: Specifies if the calculation should be grouped by certain criteria
rolling: Specifies the rolling window overwhich to perform the calculation
addToDataframe: Indicates if the result should be added to the original dataframe

Examples

Example 1 - Get Variance of a Single Column

You can calculate the variance of a single numeric column to understand the spread of values. In this example, we compute the variance of the RISK_MM column, which provides insight into how much the expected rainfall measurement varies day to day.
#> ColumnVariance RISK_MM --print
AFLEFT 
weatherDfVar = weatherDf['RISK_MM'].var()
print(weatherDfVar) #)2 AFRIGHT

Example 2 - Get Variance for Multiple Columns

You can also retrieve the variance for several columns at once. This example calculates the variance of both WindSpeed3pm and Evaporation, which helps evaluate the variability in those measurements.
#> ColumnVariance WindSpeed3pm Evaporation --print
AFLEFT 
weatherDfVar = weatherDf [ ['WindSpeed3pm', 'Evaporation'] ].var()
print(weatherDfVar) #)4 AFRIGHT