diff --git a/pandas/io/data.py b/pandas/io/data.py index e875e8aa3c6db..525a7ce64f0c2 100644 --- a/pandas/io/data.py +++ b/pandas/io/data.py @@ -664,7 +664,9 @@ def _get_option_data(self, month, year, expiry, table_loc, name): "element".format(url)) tables = root.xpath('.//table') ntables = len(tables) - if table_loc - 1 > ntables: + if ntables == 0: + raise RemoteDataError("No tables found at {0!r}".format(url)) + elif table_loc - 1 > ntables: raise IndexError("Table location {0} invalid, {1} tables" " found".format(table_loc, ntables))