import pandas as pd
#Load Data, parse dates,
temp_data = pd.read_table('sample.txt', parse_dates=[0])
temp_data = temp_data.set_index(['Year'])
pd.to_datetime(temp_data.index)
temp_data
Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Year | ||||||||||||
1880-01-01 | -34 | -27 | -22 | -30 | -16 | -24 | -19 | -12 | -20 | -19 | -16 | -21 |
1881-01-01 | -13 | -16 | -2 | -3 | -3 | -27 | -12 | -8 | -18 | -23 | -28 | -18 |
1882-01-01 | 3 | 4 | -2 | -24 | -20 | -32 | -27 | -11 | -11 | -25 | -25 | -37 |
1883-01-01 | -38 | -38 | -12 | -20 | -20 | -8 | -3 | -13 | -19 | -19 | -28 | -21 |
1884-01-01 | -20 | -14 | -31 | -36 | -33 | -36 | -31 | -24 | -29 | -25 | -29 | -25 |
1885-01-01 | -57 | -29 | -19 | -36 | -35 | -40 | -28 | -24 | -17 | -14 | -14 | 0 |
1886-01-01 | -37 | -43 | -34 | -23 | -21 | -30 | -13 | -21 | -12 | -22 | -29 | -18 |
1887-01-01 | -60 | -43 | -26 | -34 | -28 | -25 | -19 | -28 | -24 | -33 | -29 | -40 |
from bokeh.plotting import figure, output_file, show
import pandas as pd
from bokeh.palettes import Spectral11
from bokeh.io import output_notebook
output_notebook()
#Load Data, parse dates,
temp_data = pd.read_table('sample.txt', parse_dates=[0])
temp_data = temp_data.set_index(['Year'])
pd.to_datetime(temp_data.index)
#the number of colums is the number of lines that we will make
numlines = len(temp_data.columns)
#import color pallet
mypalette = Spectral11[0:numlines]
# make a list of our colums
col = []
[col.append(i) for i in temp_data.columns]
# make the figure,
p1 = figure(x_axis_type="datetime", title="Multi Line", width = 800, height = 450)
p1.xaxis.axis_label = 'Year'
p1.yaxis.axis_label = 'Temp'
# loop through our colums and colors
for (month, colore) in zip(col, mypalette):
p1.line(temp_data.index, temp_data[month], legend = month, color = colore )
show(p1)
<Bokeh Notebook handle for In[4]>