DEV Community

loading...

Day 63 Of 100DaysOfCode: Pandas Dispersion

iamdurga profile image Durga Pokharel ・2 min read

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]
print(bounds)

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

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

Discussion (0)

pic
Editor guide