March 2020
Beginner to intermediate
352 pages
8h 40m
English
Variance is the square of the average/mean of the difference between each value in the dataset with its average/mean; that is, it is the square of standard deviation.
Different Python libraries have functions to obtain the variance of the dataset. The NumPy library has the numpy.var(dataset) function. The statistics library has the statistics.variance(dataset) function. Using the pandas library, we calculate the variance in our df data frame using the df.var() function:
# variance of dataset using var() functionvariance=df.var()print(variance)# variance of the specific columnvar_height=df.loc[:,"height"].var()print(var_height)
The output of the preceding code is as follows:
It is essential to note the following observations from ...
Read now
Unlock full access