DEV Community

Durga Pokharel
Durga Pokharel

Posted on

Day 63 Of 100DaysOfCode: Pandas Dispersion

This is my 63th day of #100DaysOfcode and #python learning. Like yesterday today continue to learn from datacamp about pandas. Here is code for inter quantile range.

Pandas code

# Calculate mean
mean = income['Income per Capita'].mean()

# Calculate standard deviation
std = income['Income per Capita'].std()

# Calculate and print lower and upper bounds
bounds = [mean-std,mean + std]

# Calculate and print first and third quartiles
quantiles = income['Income per Capita'].quantile([0.25, 0.75])

# Calculate and print IQR
iqr = quantiles[0.75] - quantiles[0.25]
Enter fullscreen mode Exit fullscreen mode

Discussion (0)