## Difference between Mean,Mode,Median

April 04, 2019

* 128* || * 2 minutes*

<p>Suppose we have an array of 8 numbers -> 15,19,4,11,8,3,17,12</p><h1>Mean</h1><p>Mean is the usual average. So add them all and divide by the total number.</p><p>15+19+4+11+8+3+17+12 = 89</p><p>89/9 = 11.125</p><p>so mean value for this array is 11.125.</p><p><br></p><h1>Median</h1><p>Median is the middle value. So first we have to sort the array then the middle value will be median for the array.</p><p>sorted array -> 3,4,8,11,12,15,17,19</p><p>as the total number is even, we can add the two middle indexes and divide them by 2. In our case (11+12) /2=11.5</p><p><br></p><h1>Mode</h1><p>Mode is the number that has maximum instances or occurrence in the array. For example , A = [1,2,4,4,9] then mode for array A is 4 because it has the highest number of instances.</p><p><br></p><p>In pythons pandas library all these can be done be easily calling the functions provided with pandas.</p><pre>import pandas as pd
import numpy as np
data = pd.DataFrame(np.random.randint(1,20,8)) #Low,High,Size
data.mean()
data.mode()
data.median()</pre><p><br></p>