With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Measuring variance

Variance gives us a feel  for the overall amount of spread of the values from the mean. It is defined as follows:

Essentially, this is stating that for each measurement, we calculate the value of the difference between the value and the mean. This can be a positive or negative value, so we square the result to make sure that negative values have cumulative effects on the result. These values are then summed up and divided by the number of measurements minus 1, giving an approximation of the average value of the differences.

In pandas, the variance is calculated using the .var() method. The following code calculates the variance ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required