Also there are other external libraries that can help you achieve the same results in just 1 line of code as the code is pre-written in those libraries. Otherwise here is a previous answer that provides some example code for the mean and standard deviation operations. These statistic measures complement the use of the mean the median and the mode when were describing our data.
The variance and the standard deviation are commonly used to measure the variability or dispersion of a dataset.
The median is the middle number of a set of numbers. The mean value is the average value. N lendata mean sumdata n deviations x - mean 2 for x in data variance sumdeviations n return variance def stdevdata. Pandas python examplepy ----- Calculate Mean ----- Apple 16500000 Orange 11333333 Banana 11666667 Pear 16333333 dtype.