Python Practice › Pandas Programs › Program 19
Standard deviation of a Series
Write a pandas program to find the standard deviation of a Series.
Input
[2, 4, 6, 8, 10]
Output
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))Output
3.162278 2.828427
Line by line
Line 3
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.