Loading data from Yahoo! Finance with pandas

As Karl pointed out, the ticker had changed meaning Yahoo returns a 'page not found'.

When polling data from the web, it is a good idea to wrap the call in a try except

all_data = {}
for ticker in ['AAPL', 'IBM', 'MSFT', 'GOOG']:
    try:
        all_data[ticker] = web.get_data_yahoo(ticker, '1/1/2003', '1/1/2013')
        price = DataFrame({tic: data['Adj Close']
                    for tic, data in all_data.iteritems()})
        volume = DataFrame({tic: data['Volume']
                    for tic, data in all_data.iteritems()})
    except:
        print "Cant find ", ticker

Tags:

Python

Pandas