<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><ul class="toc-item"><li><span><a href="#Measures-of-central-tendancy" data-toc-modified-id="Measures-of-central-tendancy-0.1">Measures of central tendancy</a></span></li><li><span><a href="#Measuring-dispersion---Inter-Quartile-Ranges" data-toc-modified-id="Measuring-dispersion---Inter-Quartile-Ranges-0.2">Measuring dispersion - Inter Quartile Ranges</a></span></li><li><span><a href="#Histogram-of-sales-data" data-toc-modified-id="Histogram-of-sales-data-0.3">Histogram of sales data</a></span></li></ul></li><li><span><a href="#Measures-of-dispersion---Standard-Deviation" data-toc-modified-id="Measures-of-dispersion---Standard-Deviation-1">Measures of dispersion - Standard Deviation</a></span><ul class="toc-item"><li><ul class="toc-item"><li><span><a href="#Coefficient-of-variability" data-toc-modified-id="Coefficient-of-variability-1.0.1">Coefficient of variability</a></span></li></ul></li><li><span><a href="#Dispersion-based-on-percentiles" data-toc-modified-id="Dispersion-based-on-percentiles-1.1">Dispersion based on percentiles</a></span></li><li><span><a href="#Correlation-coefficient" data-toc-modified-id="Correlation-coefficient-1.2">Correlation coefficient</a></span></li><li><span><a href="#When-is-big-data-needed?" data-toc-modified-id="When-is-big-data-needed?-1.3">When is big data needed?</a></span></li></ul></li></ul></div>
Data Description
Step1:  Measures of central tendancy
Step2:  Measuring dispersion - Inter Quartile Ranges
Step3:  Histogram of sales data
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
sales_data = pd.read_csv('datasets_csv/CH03/ex3-14.txt')
sales_data.columns = ['Year', 'Month', 'Sales'] #strip out the double quotes
sales_data.head()
Explanation: <h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><ul class="toc-item"><li><span><a href="#Measures-of-central-tendancy" data-toc-modified-id="Measures-of-central-tendancy-0.1">Measures of central tendancy</a></span></li><li><span><a href="#Measuring-dispersion---Inter-Quartile-Ranges" data-toc-modified-id="Measuring-dispersion---Inter-Quartile-Ranges-0.2">Measuring dispersion - Inter Quartile Ranges</a></span></li><li><span><a href="#Histogram-of-sales-data" data-toc-modified-id="Histogram-of-sales-data-0.3">Histogram of sales data</a></span></li></ul></li><li><span><a href="#Measures-of-dispersion---Standard-Deviation" data-toc-modified-id="Measures-of-dispersion---Standard-Deviation-1">Measures of dispersion - Standard Deviation</a></span><ul class="toc-item"><li><ul class="toc-item"><li><span><a href="#Coefficient-of-variability" data-toc-modified-id="Coefficient-of-variability-1.0.1">Coefficient of variability</a></span></li></ul></li><li><span><a href="#Dispersion-based-on-percentiles" data-toc-modified-id="Dispersion-based-on-percentiles-1.1">Dispersion based on percentiles</a></span></li><li><span><a href="#Correlation-coefficient" data-toc-modified-id="Correlation-coefficient-1.2">Correlation coefficient</a></span></li><li><span><a href="#When-is-big-data-needed?" data-toc-modified-id="When-is-big-data-needed?-1.3">When is big data needed?</a></span></li></ul></li></ul></div>
Data Description
End of explanation
print('Mean ' + str(sales_data.Sales.mean()))
print('Median ' + str(sales_data.Sales.median()))
print('Mode ' + str(sales_data.Sales.mode()))
Explanation: Measures of central tendancy
End of explanation
quartiles = sales_data.Sales.quantile(q=[0.25, 0.5, 0.75])
quartiles
IQR = quartiles[0.75] - quartiles[0.25]
IQR
Explanation: Measuring dispersion - Inter Quartile Ranges
End of explanation
#create a subplot to show box plot and histogram next to each other
fig, axs = plt.subplots(nrows=2, ncols=1, figsize=(8,10))
#plot a histogram using Pandas.
hax = sales_data.Sales.hist(ax = axs[0], bins=15, grid=False)
hax.set_title('Histogram of Sales data')
#get the axis bounds
hax_bounds = hax.axis()
#plot the mean in black
mean = sales_data.Sales.mean()
hax.vlines(mean, hax_bounds[2], hax_bounds[3], label='Mean = ' + str(mean))
#plot the median in yellow
median= sales_data.Sales.median()
hax.vlines(median, hax_bounds[2], hax_bounds[3], label='Median = ' + str(median), colors='yellow')
#plot the mode in red
mode= sales_data.Sales.mode()[0]
hax.vlines(mode, hax_bounds[2], hax_bounds[3], label='Mode = ' + str(mode), colors='red')
#Get the standard deviation
sd = sales_data.Sales.std()
#get mean +- 1SD lines
m1sd = mean + 1*sd
m1negsd = mean - 1*sd
hax.vlines(m1sd, hax_bounds[2], hax_bounds[3], label='Mean + 1SD = ' + str(m1sd), colors='cyan')
hax.vlines(m1negsd, hax_bounds[2], hax_bounds[3], label='SD = ' + str(sd), colors='cyan')
hax.legend()
############## plot 2
#now plot the box plot
bax = sales_data.Sales.plot(kind='box', ax = axs[1], title = 'Boxplot of Sales data', vert=False)
#vert False to make it horizontal
#Get the quartiles
quartiles = sales_data.Sales.quantile([0.25, 0.5, 0.75])
bax.text(quartiles[0.25], 0.75, r'$Q_{0.25}= ' + str(quartiles[0.25])+'$')
bax.text(quartiles[0.75], 0.75, r'$Q_{0.75}= ' + str(quartiles[0.75])+'$')
#Calculate the IQR
iqr = quartiles[0.75] - quartiles[0.25]
bax.text(x=150, y=1.25, s='IQR = ' + str(iqr))
#Get the Left inner quartile
liq = quartiles[0.25] - 1.5*iqr
bax.text(x=liq, y=0.85, s=str(liq))
#Get the right inner quartile
riq = quartiles[0.75] + 1.5*iqr
bax.text(x=riq, y=0.85, s=str(riq))
Explanation: Histogram of sales data
End of explanation
<END_TASK>