pandas, Plotly & Cufflinks

plotly is a plotting engine for fast easy generation of interactive D3.js plots. Cf. http://plot.ly.


In [2]:
import numpy as np
import pandas as pd
import pandas.io.data as web
import plotly.plotly as py
import cufflinks as cf

In [3]:
py.sign_in('Python-Demo-Account', 'gwt101uhh0')

Reading Financial Data


In [4]:
symbols = ['AAPL', 'MSFT', 'YHOO']

In [5]:
data = pd.DataFrame()
for sym in symbols:
    data[sym] = web.DataReader(sym, data_source='yahoo')['Adj Close']

In [6]:
data.tail()


Out[6]:
AAPL MSFT YHOO
Date
2015-07-31 120.753419 46.700001 36.669998
2015-08-03 117.906306 46.810001 36.689999
2015-08-04 114.123426 47.540001 37.119999
2015-08-05 114.880003 47.580002 37.250000
2015-08-06 115.129997 46.619999 36.459999

Plotting the Data


In [7]:
data.iplot(filename='financial', world_readable=True)


Out[7]:

In [8]:
data['AAPL'].iplot(filename='best_fit', bestfit=True, colors=['pink'],
                bestfit_colors=['blue'], world_readable=True)


Out[8]: