In [ ]:
import bokeh
bokeh.load_notebook()
In [ ]:
from collections import OrderedDict
import pandas as pd
from bokeh.charts import TimeSeries
# Here is some code to read in some stock data from the Yahoo Finance API
AAPL = pd.read_csv(
"http://ichart.yahoo.com/table.csv?s=AAPL&a=0&b=1&c=2000&d=0&e=1&f=2010",
parse_dates=['Date'])
MSFT = pd.read_csv(
"http://ichart.yahoo.com/table.csv?s=MSFT&a=0&b=1&c=2000&d=0&e=1&f=2010",
parse_dates=['Date'])
IBM = pd.read_csv(
"http://ichart.yahoo.com/table.csv?s=IBM&a=0&b=1&c=2000&d=0&e=1&f=2010",
parse_dates=['Date'])
xyvalues = OrderedDict(
AAPL=AAPL['Adj Close'],
Date=AAPL['Date'],
MSFT=MSFT['Adj Close'],
IBM=IBM['Adj Close'],
)
ts = TimeSeries(xyvalues, index='Date', title="timeseries, pd_input", legend='top_left',ylabel='Stock Prices', notebook=True)
ts.legend("top_left").show()
In [ ]:
import pandas as pd
df = pd.DataFrame(xyvalues)
ts = TimeSeries(df, index='Date', title="timeseries, pd_input", legend='top_left',notebook=True)
ts.show()
In [ ]:
from bokeh.plotting import output_notebook, show
output_notebook()
lindex = xyvalues.pop('Date')
lxyvalues = list(xyvalues.values())
ts = TimeSeries(lxyvalues, index=lindex, title="timeseries, pd_input", y_label='Stock Prices: 1-AAPL, 2-IBM, 3-MSFT', legend='top_left', notebook=True)
show(ts)
In [ ]: