Skip to content

Commit a44e4b3

Browse files
DEPR: also deprecate io/wb.py (GH10861)
1 parent dacae10 commit a44e4b3

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

pandas/io/wb.py

+27-18
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,20 @@
99
import numpy as np
1010
import warnings
1111

12+
warnings.warn("\n"
13+
"The pandas.io.wb module is moved to a separate package "
14+
"(pandas-datareader) and will be removed from pandas in a "
15+
"future version.\nAfter installing the pandas-datareader package "
16+
"(https://github.com/pydata/pandas-datareader), you can change "
17+
"the import ``from pandas.io import data, wb`` to "
18+
"``from pandas_datareader import data, wb``.",
19+
FutureWarning)
20+
21+
1222
# This list of country codes was pulled from wikipedia during October 2014.
1323
# While some exceptions do exist, it is the best proxy for countries supported
14-
# by World Bank. It is an aggregation of the 2-digit ISO 3166-1 alpha-2, and
15-
# 3-digit ISO 3166-1 alpha-3, codes, with 'all', 'ALL', and 'All' appended ot
24+
# by World Bank. It is an aggregation of the 2-digit ISO 3166-1 alpha-2, and
25+
# 3-digit ISO 3166-1 alpha-3, codes, with 'all', 'ALL', and 'All' appended ot
1626
# the end.
1727

1828
country_codes = ['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', \
@@ -83,35 +93,35 @@ def download(country=['MX', 'CA', 'US'], indicator=['NY.GDP.MKTP.CD', 'NY.GNS.IC
8393
8494
indicator: string or list of strings
8595
taken from the ``id`` field in ``WDIsearch()``
86-
96+
8797
country: string or list of strings.
8898
``all`` downloads data for all countries
8999
2 or 3 character ISO country codes select individual
90100
countries (e.g.``US``,``CA``) or (e.g.``USA``,``CAN``). The codes
91101
can be mixed.
92-
102+
93103
The two ISO lists of countries, provided by wikipedia, are hardcoded
94104
into pandas as of 11/10/2014.
95-
105+
96106
start: int
97107
First year of the data series
98-
108+
99109
end: int
100110
Last year of the data series (inclusive)
101-
111+
102112
errors: str {'ignore', 'warn', 'raise'}, default 'warn'
103113
Country codes are validated against a hardcoded list. This controls
104114
the outcome of that validation, and attempts to also apply
105115
to the results from world bank.
106-
116+
107117
errors='raise', will raise a ValueError on a bad country code.
108-
118+
109119
Returns
110120
-------
111121
112-
``pandas`` DataFrame with columns: country, iso_code, year,
122+
``pandas`` DataFrame with columns: country, iso_code, year,
113123
indicator value.
114-
124+
115125
"""
116126

117127
if type(country) == str:
@@ -130,7 +140,7 @@ def download(country=['MX', 'CA', 'US'], indicator=['NY.GDP.MKTP.CD', 'NY.GNS.IC
130140
# Work with a list of indicators
131141
if type(indicator) == str:
132142
indicator = [indicator]
133-
143+
134144
# Download
135145
data = []
136146
bad_indicators = {}
@@ -165,12 +175,12 @@ def download(country=['MX', 'CA', 'US'], indicator=['NY.GDP.MKTP.CD', 'NY.GNS.IC
165175

166176
def _get_data(indicator="NY.GNS.ICTR.GN.ZS", country='US',
167177
start=2002, end=2005):
168-
178+
169179
if type(country) == str:
170180
country = [country]
171-
181+
172182
countries = ';'.join(country)
173-
183+
174184
# Build URL for api call
175185
url = ("http://api.worldbank.org/countries/" + countries + "/indicators/" +
176186
indicator + "?date=" + str(start) + ":" + str(end) +
@@ -195,11 +205,11 @@ def _get_data(indicator="NY.GNS.ICTR.GN.ZS", country='US',
195205
wb_err += msg['value']
196206
error_msg = "Problem with a World Bank Query \n %s"
197207
return None, error_msg % wb_err
198-
208+
199209
if 'total' in possible_message.keys():
200210
if possible_message['total'] == 0:
201211
return None, "No results from world bank."
202-
212+
203213
# Parse JSON file
204214
data = json.loads(data)[1]
205215
country = [x['country']['value'] for x in data]
@@ -296,4 +306,3 @@ def search(string='gdp.*capi', field='name', case=False):
296306
idx = data.str.contains(string, case=case)
297307
out = _cached_series.ix[idx].dropna()
298308
return out
299-

0 commit comments

Comments
 (0)