<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 1.) Import the modules we will need
Step1:  2.) Preview the raw data
Step2:  3.) Now for the charts
There are several charting library in Python, and we will look at some of the most popular today. We will start with building some absolute basics, like bar and line charts, then move on to something a little more fun. All the charts charts below are feed our DataFrame object we created earlier.
3.1) MatPlotLib
The first is MatPlotLib, the grand-daddy of them all. Its powerful, flexable, and totally ubiquitous. Unfortunatly, with great power comes great complexity. Here is an example of how to draw a simple line chart using the matplotlib api only. Today MatPlotLib is usually used as a base libray that is further abstracted by higher level tools.
http
Step3:  3.2) Pandas
Pandas uses matplotlib internally as its low level graphing api, but presents us with an api that abstracts away the complexity. This leaves us with a simple api to produce charts and graphs, while still having the raw power to customize should we be so bold.
http
Step4:  Bar Chart
Step5:  Histogram
Step6:  Stacked Bar Chart
Step7:  3.3) Bokeh
Bokeh is a Python interactive visualization library that targets modern web browsers for presentation. Its goal is to provide elegant, concise construction of novel graphics in the style of D3.js, and to extend this capability with high-performance interactivity over very large or streaming datasets.
http
Step8:  Interactive Bar Chart
Step9:  Interactive Histogram
<ASSISTANT_TASK:>
Python Code:
from __future__ import division, unicode_literals
import pandas as pd
import numpy as np
import matplotlib
%matplotlib inline
matplotlib.style.use('ggplot')
Explanation: 1.) Import the modules we will need
End of explanation
df = pd.read_excel('./input/complete_data.xls')
df.head()
Explanation: 2.) Preview the raw data
End of explanation
import datetime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.cbook as cbook
years = mdates.YearLocator()   # every year
months = mdates.MonthLocator()  # every month
yearsFmt = mdates.DateFormatter('%Y')
# load up some sample data to plot
datafile = cbook.get_sample_data('goog.npy')
r = np.load(datafile, encoding='bytes').view(np.recarray)
fig, ax = plt.subplots()
ax.plot(r.date, r.adj_close)
# format the ticks
ax.xaxis.set_major_locator(years)
ax.xaxis.set_major_formatter(yearsFmt)
ax.xaxis.set_minor_locator(months)
datemin = datetime.date(r.date.min().year, 1, 1)
datemax = datetime.date(r.date.max().year + 1, 1, 1)
ax.set_xlim(datemin, datemax)
# format the coords message box
def price(x):
    return '$%1.2f' % x
ax.format_xdata = mdates.DateFormatter('%Y-%m-%d')
ax.format_ydata = price
ax.grid(True)
# rotates and right aligns the x labels, and moves the bottom of the
# axes up to make room for them
fig.autofmt_xdate()
plt.show()
Explanation: 3.) Now for the charts
There are several charting library in Python, and we will look at some of the most popular today. We will start with building some absolute basics, like bar and line charts, then move on to something a little more fun. All the charts charts below are feed our DataFrame object we created earlier.
3.1) MatPlotLib
The first is MatPlotLib, the grand-daddy of them all. Its powerful, flexable, and totally ubiquitous. Unfortunatly, with great power comes great complexity. Here is an example of how to draw a simple line chart using the matplotlib api only. Today MatPlotLib is usually used as a base libray that is further abstracted by higher level tools.
http://matplotlib.org/
End of explanation
sales_by_month = df[['date', 'quantity']].set_index('date')
sales_by_month.resample('M', how=sum).plot(title="Total Sales by Month")
Explanation: 3.2) Pandas
Pandas uses matplotlib internally as its low level graphing api, but presents us with an api that abstracts away the complexity. This leaves us with a simple api to produce charts and graphs, while still having the raw power to customize should we be so bold.
http://pandas.pydata.org/pandas-docs/stable/visualization.html
Line Chart
End of explanation
summary = df[['ext price', 'name']].groupby('name').sum()
summary.plot(kind='bar', title="Total Sales by Account")
Explanation: Bar Chart
End of explanation
purchase_patterns = df[['ext price','date']]
purchase_patterns.head()
purchase_plot = purchase_patterns['ext price'].hist(bins=40)
purchase_plot.set_title("Purchase Patterns")
purchase_plot.set_xlabel("Order Amount($)")
purchase_plot.set_ylabel("Number of orders")
Explanation: Histogram
End of explanation
sales_by_sku=df[['name', 'sku', 'ext price']].groupby(['name', 'sku']).sum()
sales_by_sku.head()
sales_by_sku.unstack().head()
my_plot = sales_by_sku.unstack().plot(kind='bar',stacked=True, title="Total Sales by Customer and SKU", legend=None)
my_plot.set_xlabel("Customers")
my_plot.set_ylabel("Sales")
Explanation: Stacked Bar Chart
End of explanation
from bokeh.charts import Bar, Histogram, show, output_notebook
output_notebook()
Explanation: 3.3) Bokeh
Bokeh is a Python interactive visualization library that targets modern web browsers for presentation. Its goal is to provide elegant, concise construction of novel graphics in the style of D3.js, and to extend this capability with high-performance interactivity over very large or streaming datasets.
http://bokeh.pydata.org/en/latest/
End of explanation
b = Bar(summary, label='name', values='ext price', title="Total Sales by Account")
show(b)
Explanation: Interactive Bar Chart
End of explanation
hist = Histogram(df, values='ext price', bins=40, legend=True)
show(hist)
Explanation: Interactive Histogram
End of explanation
<END_TASK>