|
2 | 2 |
|
3 | 3 | from __future__ import print_function
|
4 | 4 |
|
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 |
6 | 9 | from pandas.io.common import urlopen
|
7 | 10 | from pandas.io import json
|
8 | 11 | import pandas
|
9 | 12 | import numpy as np
|
10 |
| -import warnings |
11 | 13 |
|
| 14 | +PD017 = LooseVersion(pandas.__version__) > LooseVersion('0.16.2') |
12 | 15 | # This list of country codes was pulled from wikipedia during October 2014.
|
13 | 16 | # While some exceptions do exist, it is the best proxy for countries supported
|
14 | 17 | # 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
|
155 | 158 | out = reduce(lambda x, y: x.merge(y, how='outer'), data)
|
156 | 159 | out = out.drop('iso_code', axis=1)
|
157 | 160 | 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) |
159 | 167 | return out
|
160 | 168 | else:
|
161 | 169 | msg = "No indicators returned data."
|
|
0 commit comments