diff --git a/pandas_datareader/wb.py b/pandas_datareader/wb.py index 1010b6e0..47246f08 100644 --- a/pandas_datareader/wb.py +++ b/pandas_datareader/wb.py @@ -2,6 +2,8 @@ from __future__ import print_function +from distutils.version import LooseVersion + from pandas.compat import map, reduce, range, lrange from pandas.io.common import urlopen from pandas.io import json @@ -9,6 +11,7 @@ import numpy as np import warnings +PD017 = LooseVersion(pandas.__version__) >= LooseVersion('0.16.2') # This list of country codes was pulled from wikipedia during October 2014. # While some exceptions do exist, it is the best proxy for countries supported # by World Bank. It is an aggregation of the 2-digit ISO 3166-1 alpha-2, and @@ -155,7 +158,8 @@ def download(country=['MX', 'CA', 'US'], indicator=['NY.GDP.MKTP.CD', 'NY.GNS.IC out = reduce(lambda x, y: x.merge(y, how='outer'), data) out = out.drop('iso_code', axis=1) out = out.set_index(['country', 'year']) - out = out.convert_objects(convert_numeric=True) + kw = 'numeric' if PD017 else 'convert_numeric' + out = out.convert_objects(**{kw: True}) return out else: msg = "No indicators returned data."