Skip to content

Commit e1e177c

Browse files
BUG: Fix crash on empty table
Fixes #22
1 parent 1cb3bb7 commit e1e177c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pandas_datareader/data.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,6 @@ def _option_frames_from_url(self, url):
701701
calls = frames[self._TABLE_LOC['calls']]
702702
puts = frames[self._TABLE_LOC['puts']]
703703

704-
if len(calls) == 0 or len(puts) == 0:
705-
raise RemoteDataError('Received no data from Yahoo at url: %s' % url)
706-
707704
calls = self._process_data(calls, 'call')
708705
puts = self._process_data(puts, 'put')
709706

pandas_datareader/tests/test_data.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def setUpClass(cls):
280280
cls.dirpath = tm.get_data_path()
281281
cls.html1 = os.path.join(cls.dirpath, 'yahoo_options1.html')
282282
cls.html2 = os.path.join(cls.dirpath, 'yahoo_options2.html')
283+
cls.html3 = os.path.join(cls.dirpath, 'yahoo_options3.html') #Empty table GH#22
283284
cls.data1 = cls.aapl._option_frames_from_url(cls.html1)['puts']
284285

285286
@classmethod
@@ -398,6 +399,11 @@ def test_month_year(self):
398399

399400
self.assertTrue(len(data) > 1)
400401

402+
def test_empty_table(self):
403+
#GH22
404+
empty = self.aapl._option_frames_from_url(self.html3)['puts']
405+
self.assertTrue(len(empty) == 0)
406+
401407

402408
class TestOptionsWarnings(tm.TestCase):
403409
@classmethod
@@ -410,7 +416,7 @@ def tearDownClass(cls):
410416

411417
def test_options_source_warning(self):
412418
if not assert_produces_warning:
413-
raise SkipTest("old version of pandas without "
419+
raise nose.SkipTest("old version of pandas without "
414420
"compat.assert_produces_warning")
415421
with assert_produces_warning():
416422
aapl = web.Options('aapl')
@@ -426,6 +432,7 @@ def test_read_yahoo(self):
426432
assert isinstance(gs, DataFrame)
427433

428434
def test_read_google(self):
435+
raise nose.SkipTest("Google API deprecated")
429436
gs = DataReader("GS", "google")
430437
assert isinstance(gs, DataFrame)
431438

0 commit comments

Comments
 (0)