6. Making Things Interactive with Bokeh
Activity 6.01: Plotting Mean Car Prices of Manufacturers
Solution:
- Create an
Activity6.01.ipynb
Jupyter notebook in theChapter06/Activity6.01
folder. - Import the necessary libraries:
import pandas as pd from bokeh.io import output_notebook output_notebook()
- Load the
automobiles.csv
dataset from theDatasets
folder:dataset = pd.read_csv('../../Datasets/automobiles.csv')
- Use the
head
method to print the first five rows of the dataset:dataset.head()
The following figure shows the output of the preceding code:
Plotting each car with its price
- Use the
plotting
interface of Bokeh to do some basic visualization first. Let's plot each car with its price. Importfigure
andshow
from thebokeh.plotting
interface:from bokeh.plotting import figure, show
- First, use the index as our x-axis since we just want to plot each car with its price...