Posts

Showing posts with the label #bar chart

How to calculate Mean, Median and Mode in python

#CALCULATE MEAN import numpy as np speed = [ 99 , 86 , 87 , 88 , 111 , 86 , 103 , 87 , 94 , 78 , 77 , 85 , 86 ] x = np. mean (speed) print (x) #CALCULATE MEDIAN import numpy as np speed = [ 99 , 86 , 87 , 88 , 111 , 86 , 103 , 87 , 94 , 78 , 77 , 85 , 86 ] x = np. median (speed) print (x) #CALCULATE MODE from scipy import stats speed = [ 99 , 86 , 87 , 88 , 111 , 86 , 103 , 87 , 94 , 78 , 77 , 85 , 86 ] x = stats. mode (speed) print (x)

How to generate bar chart in python

import matplotlib.pyplot as plt import numpy as np x = np. array ([ "A" , "B" , "C" , "D" ]) y = np. array ([ 4 , 5 , 3 , 7 ]) #change colour #horizontal bars plt. barh (x,y, color = "g" ) plt. show ()