SymbolWarning: Failed to read symbol replacing with NaN
<p>I'm trying to use pandas to download historical stock data for all Stockholm Large Cap stocks. It works fine but for some stocks it doesn't. </p>

<pre><code>import pandas_datareader.data as pdr
import datetime
import csv

with open('stockholm_largecap.csv', 'rb') as f:
    reader = csv.reader(f)
    stockholmLargeCap = list(reader)

start = datetime.datetime(1970, 1, 1)
end = datetime.datetime.today();

stockData = {}

for symbol in stockholmLargeCap:
    f = pdr.DataReader(symbol, 'yahoo', start, end)
    print f
</code></pre>

<p>The stockholm_largecap.csv contains all stocks in alphabetical order but once I get to certain stocks I get (for example BETS-B.ST): SymbolWarning: Failed to read symbol: 'BETS-B.ST', replacing with NaN. and the script terminates. Is there some way to continue the program, ignoring the error and what could be the cause of some stocks not working?</p>

<pre><code>raise RemoteDataError(msg.format(self.__class__.__name__))
pandas_datareader._utils.RemoteDataError: No data fetched using 'YahooDailyReader'
</code></pre>

<p>use <code>try</code> and <code>except</code></p>

<pre><code>import pandas_datareader.data as pdr

for symbol in ['SPY', 'holla']:
    try:
        f = pdr.DataReader(symbol, 'yahoo', "2001-01-01", "2010-01-01")
        print f.head(5)
    except:
        print ('did not find: '+symbol)

               Open     High      Low    Close    Volume  Adj Close
Date                                                               
2001-01-02 132.0000 132.1562 127.5625 128.8125   8737500    95.2724
2001-01-03 128.3125 136.0000 127.6562 135.0000  19431600    99.8488
2001-01-04 134.9375 135.4687 133.0000 133.5468   9219000    98.7740
2001-01-05 133.4687 133.6250 129.1875 129.1875  12911400    95.5497
2001-01-08 129.8750 130.1875 127.6875 130.1875   6625300    96.2893
did not find: holla
</code></pre>

python pandas anaconda