# How to Find Mean, Median and Mode Using Python

Before calculating mean, median and mode, let us look at types of data and characteristics of the data. At a very high level data can be classified as categorical and quantitative data. Both can be further classified as below

 Difference Order Similar Interval Meaningful Zero Categorical Nominal (Cities) Yes – – – Categorical Ordinal (Temp.) Yes Yes – – Quantitative Interval Yes Yes Yes – Quantitative Ration Yes Yes Yes Yes

Now all of these types of data do not have all characteritics

 Mode Median Mean Nominal Yes – – Ordinal Yes – – interval Yes Yes Yes ratio Yes Yes Yes

Mean:

Mean is nothing but average. It can be calculated in python or by using numpy

Median

Middle value of observation when ordered from low to high

Mode

Mots commonly occurring observation

 ################################################################################################ # name: discriptive_statistics_01.py # desc: identify type of progression # date: 2018-12-22 # Author: conquistadorjd ################################################################################################ import numpy as np from scipy import stats #Calculate mean by python input_data = input('Input elements separated by comma :') # Convert input into List input_list = list(map(int, input_data.split(','))) print ("input_list", input_list , type(input_list)) # Mean calculation using simple python mean = sum(input_list)/ len(input_list) print('mean', mean) # Mean calculation using numpy mean = np.mean(input_list) print('mean', mean) # Median calculation using numpy median = np.median(input_list) print('median', median) # Mode calculation using scipy mode = stats.c(input_list) print('mode', mode)

This site uses Akismet to reduce spam. Learn how your comment data is processed.