From a8c45690398fa07c3ae3afd391af89a9b8bf3072 Mon Sep 17 00:00:00 2001 From: David Stephens Date: Sun, 9 Nov 2014 12:28:47 -0800 Subject: [PATCH] TST: Raise remote data error if no expiry dates are found (io.data.Options) --- doc/source/whatsnew/v0.15.2.txt | 1 + pandas/io/data.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.15.2.txt b/doc/source/whatsnew/v0.15.2.txt index 66b839ed01a29..8f8220961b0f4 100644 --- a/doc/source/whatsnew/v0.15.2.txt +++ b/doc/source/whatsnew/v0.15.2.txt @@ -43,3 +43,4 @@ Experimental Bug Fixes ~~~~~~~~~ - Bug in ``groupby`` signatures that didn't include *args or **kwargs (:issue:`8733`). +- ``io.data.Options`` now raises ``RemoteDataError`` when no expiry dates are available from Yahoo (:issue:`8761`). \ No newline at end of file diff --git a/pandas/io/data.py b/pandas/io/data.py index 982755a854e36..d69343817a63f 100644 --- a/pandas/io/data.py +++ b/pandas/io/data.py @@ -1132,10 +1132,13 @@ def _get_expiry_dates_and_links(self): expiry_dates = [dt.datetime.strptime(element.text, "%B %d, %Y").date() for element in links] links = [element.attrib['data-selectbox-link'] for element in links] + + if len(expiry_dates) == 0: + raise RemoteDataError('Data not available') + expiry_links = dict(zip(expiry_dates, links)) self._expiry_links = expiry_links self._expiry_dates = expiry_dates - return expiry_dates, expiry_links def _parse_url(self, url):