Skip to content

Commit

Permalink
Merge pull request #50 from bashtage/update-convert-objects
Browse files Browse the repository at this point in the history
UPD: Update for upstream changes in DataFrame.convert_objects
  • Loading branch information
bashtage committed Jul 20, 2015
2 parents 17eb2d2 + debb437 commit e0cb350
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pandas_datareader/wb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit e0cb350

Please sign in to comment.