Standard deviation of a Series
Write a pandas program to find the standard deviation of a Series.
[2, 4, 6, 8, 10]
3.162278 2.828427
Approach
std()uses the sample formula (ddof=1).
Solution
import pandas as pds = pd.Series([2, 4, 6, 8, 10])print(round(s.std(), 6), round(s.std(ddof=0), 6))3.162278 2.828427
Line by line
pandas divides by n – 1 by default; ddof=0 divides by n like NumPy.
Learn the concept
New to this topic? Read the lesson, then come back.