Skip to content

Commit debb437

Browse files
author
Kevin Sheppard
committed
UPD: Update for upstream changes in DataFrame.convert_objects
Update convert_objects use to new syntax. xref pandas-dev/pandas#10265
1 parent 17eb2d2 commit debb437

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pandas_datareader/wb.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
from __future__ import print_function
44

5-
from pandas.compat import map, reduce, range, lrange
5+
from distutils.version import LooseVersion
6+
import warnings
7+
8+
from pandas.compat import reduce, lrange
69
from pandas.io.common import urlopen
710
from pandas.io import json
811
import pandas
912
import numpy as np
10-
import warnings
1113

14+
PD017 = LooseVersion(pandas.__version__) > LooseVersion('0.16.2')
1215
# This list of country codes was pulled from wikipedia during October 2014.
1316
# While some exceptions do exist, it is the best proxy for countries supported
1417
# 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
155158
out = reduce(lambda x, y: x.merge(y, how='outer'), data)
156159
out = out.drop('iso_code', axis=1)
157160
out = out.set_index(['country', 'year'])
158-
out = out.convert_objects(convert_numeric=True)
161+
if PD017:
162+
kwargs = dict((kw, True)
163+
for kw in ('datetime', 'numeric', 'timedelta'))
164+
else:
165+
kwargs = {'convert_numeric': True}
166+
out = out.convert_objects(**kwargs)
159167
return out
160168
else:
161169
msg = "No indicators returned data."

0 commit comments

Comments
 (0)