Calculate standard deviation of a dictionary in Python Last Updated : 31 Aug, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Python dictionary is a versatile data structure that allows a lot of operations to be done without any hassle. Calculating the standard deviation is shown below. Example #1: Using numpy.std() First, we create a dictionary. Then we store all the values in a list by iterating over it. After this using the NumPy we calculate the standard deviation of the list. Python3 # importing numpy import numpy as np # creating our test dictionary dicti = {'a': 20, 'b': 32, 'c': 12, 'd': 93, 'e': 84} # declaring an empty list listr = [] # appending all the values in the list for value in dicti.values(): listr.append(value) # calculating standard deviation using np.std std = np.std(listr) # printing results print(std) Output: 33.63569532505609 Example #2: Using list comprehension First, we create a list of values from the dictionary using a loop. Then we calculate mean, variance and then the standard deviation. Python3 # creating our test dictionary dicti = {'a': 20, 'b': 32, 'c': 12, 'd': 93, 'e': 84} # declaring an empty list listr = [] # appending all the values in the list for value in dicti.values(): listr.append(value) # Standard deviation of list # Using sum() + list comprehension mean = sum(listr) / len(listr) variance = sum([((x - mean) ** 2) for x in listr]) / len(listr) res = variance ** 0.5 print(res) Output: 33.63569532505609 Example #3: Using pstdev() Pythons inbuilt statistics library provides a function to compute the standard deviation of a given list. Python3 # importing the module import statistics # creating the test dictionary dicti = {'a': 20, 'b': 32, 'c': 12, 'd': 93, 'e': 84} # declaring an empty list listr = [] # appending all the values in the list for value in dicti.values(): listr.append(value) # Standard deviation of list # Using pstdev() res = statistics.pstdev(listr) print(res) Output: 33.63569532505609 Comment More infoAdvertise with us Next Article Calculate standard deviation of a dictionary in Python T technikue20 Follow Improve Article Tags : Python Python dictionary-programs Practice Tags : python Similar Reads Calculate standard deviation of a Matrix in Python In this article we will learn how to calculate standard deviation of a Matrix using Python. Standard deviation is used to measure the spread of values within the dataset. It indicates variations or dispersion of values in the dataset and also helps to determine the confidence in a modelâs statistica 2 min read Calculate pooled standard deviation in Python We are quite aware that the Standard deviations are for measuring the spread of the numbers in the datasets. The smaller standard deviations suggest that the deviations in the elements are very small or quite insignificant from the mean values of the data sets & the larger deviations suggest a s 4 min read How to calculate probability in a normal distribution given mean and standard deviation in Python? A normal distribution is a type of continuous probability distribution for a real-valued random variable. It is based on mean and standard deviation. The probability distribution function or PDF computes the likelihood of a single point in the distribution. The general formula to calculate PDF for t 2 min read Python | Pandas Series.mad() to calculate Mean Absolute Deviation of a Series Pandas provide a method to make Calculation of MAD (Mean Absolute Deviation) very easy. MAD is defined as average distance between each value and mean. The formula used to calculate MAD is: Syntax: Series.mad(axis=None, skipna=None, level=None) Parameters: axis: 0 or âindexâ for row wise operation a 2 min read Creating a Pandas Series from Dictionary A Pandas Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floating point numbers, Python objects, etc.). It has to be remembered that, unlike Python lists, a Series will always contain data of the same type. Letâs see how to create a Pandas Series from P 2 min read Like