Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Calculate Variance with Python
course content

Course Content

Learning Statistics with Python

Calculate Variance with PythonCalculate Variance with Python

Calculating Variance with NumPy

In NumPy, you need to input the sequence of values (in our case, the column of the dataset) into the np.var() function, like this: np.var(df['work_year']).

Calculating Variance with pandas

In pandas, you should use the .var() method on the sequence of values (in our case, the column of the dataset), like this: df['work_year'].var().

In both cases, the results are almost the same. The differences are due to different denominators: N in NumPy, and N-1 in pandas. Check it now!

Everything was clear?

Section 3. Chapter 3
some-alt