diff --git a/pandas_datareader/wb.py b/pandas_datareader/wb.py index 1010b6e0..cba92b43 100644 --- a/pandas_datareader/wb.py +++ b/pandas_datareader/wb.py @@ -2,13 +2,16 @@ from __future__ import print_function -from pandas.compat import map, reduce, range, lrange +from distutils.version import LooseVersion +import warnings + +from pandas.compat import reduce, lrange from pandas.io.common import urlopen from pandas.io import json import pandas 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,12 @@ 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) + if PD017: + kwargs = dict((kw, True) + for kw in ('datetime', 'numeric', 'timedelta')) + else: + kwargs = {'convert_numeric': True} + out = out.convert_objects(**kwargs) return out else: msg = "No indicators returned data."