Python Practice › Pandas Programs › Program 19

Standard deviation of a Series

EasyPandas Programs · 19 of 95

Write a pandas program to find the standard deviation of a Series.

Advertisement
Input
[2, 4, 6, 8, 10]
Output
3.162278 2.828427

Approach

  1. std() uses the sample formula (ddof=1).

Solution

Python
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.

Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs