{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pandas as pd\n", "from bokeh.charts import TimeSeries\n", "from bokeh.io import output_notebook, show\n", "output_notebook()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# read in some stock data from the Yahoo Finance API\n", "AAPL = pd.read_csv(\n", " \"http://ichart.yahoo.com/table.csv?s=AAPL&a=0&b=1&c=2000&d=0&e=1&f=2010\",\n", " parse_dates=['Date'])\n", "MSFT = pd.read_csv(\n", " \"http://ichart.yahoo.com/table.csv?s=MSFT&a=0&b=1&c=2000&d=0&e=1&f=2010\",\n", " parse_dates=['Date'])\n", "IBM = pd.read_csv(\n", " \"http://ichart.yahoo.com/table.csv?s=IBM&a=0&b=1&c=2000&d=0&e=1&f=2010\",\n", " parse_dates=['Date'])\n", "\n", "data = dict(\n", " AAPL=AAPL['Adj Close'],\n", " Date=AAPL['Date'],\n", " MSFT=MSFT['Adj Close'],\n", " IBM=IBM['Adj Close'],\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ts = TimeSeries(\n", " data, x='Date', title=\"timeseries, dict input\", \n", " legend='top_left', ylabel='Stock Prices')\n", "show(ts)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "df = pd.DataFrame(data)\n", "ts = TimeSeries(\n", " df, x='Date', title=\"timeseries, pandas input\", \n", " legend='top_left', ylabel='Stock Prices')\n", "show(ts)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.3" } }, "nbformat": 4, "nbformat_minor": 0 }