From 2847c3094295564d4b4250db442bd692cc36a45a Mon Sep 17 00:00:00 2001 From: Clark Fitzgerald Date: Sun, 19 Jan 2014 21:14:22 -0800 Subject: [PATCH 1/8] changed get_countries URL --- pandas/io/wb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/wb.py b/pandas/io/wb.py index 362b7b192f746..d815bb19ec8b8 100644 --- a/pandas/io/wb.py +++ b/pandas/io/wb.py @@ -106,7 +106,7 @@ def _get_data(indicator="NY.GNS.ICTR.GN.ZS", country='US', def get_countries(): '''Query information about countries ''' - url = 'http://api.worldbank.org/countries/all?format=json' + url = 'http://api.worldbank.org/countries/?per_page=1000&format=json' with urlopen(url) as response: data = response.read() data = json.loads(data)[1] From ae239321e3f46e44dd5ee339ea2a475945fccce1 Mon Sep 17 00:00:00 2001 From: Clark Fitzgerald Date: Wed, 22 Jan 2014 06:21:07 -0800 Subject: [PATCH 2/8] Added test for wb.get_countries --- pandas/io/tests/test_wb.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pandas/io/tests/test_wb.py b/pandas/io/tests/test_wb.py index 9549372823af8..1b9fe975d7ea1 100644 --- a/pandas/io/tests/test_wb.py +++ b/pandas/io/tests/test_wb.py @@ -1,13 +1,15 @@ import nose +from nose.tools import assert_equal import pandas from pandas.compat import u from pandas.util.testing import network from pandas.util.testing import assert_frame_equal from numpy.testing.decorators import slow -from pandas.io.wb import search, download +from pandas.io.wb import search, download, get_countries import pandas.util.testing as tm + class TestWB(tm.TestCase): @slow @@ -30,7 +32,6 @@ def test_wdi_search(self): expected.index = result.index assert_frame_equal(result, expected) - @slow @network def test_wdi_download(self): @@ -43,6 +44,14 @@ def test_wdi_download(self): expected.index = result.index assert_frame_equal(result, pandas.DataFrame(expected)) + @slow + @network + def test_wdi_get_countries(self): + raise nose.SkipTest + + result = get_countries() + assert_equal(result[-1:].name, 'Zimbabwe') + if __name__ == '__main__': nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'], From ed3e35824b2063249f446f52b4a24e993976ea4e Mon Sep 17 00:00:00 2001 From: Clark Fitzgerald Date: Wed, 22 Jan 2014 19:52:34 -0800 Subject: [PATCH 3/8] commented out nose.SkipTest --- pandas/io/tests/test_wb.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/io/tests/test_wb.py b/pandas/io/tests/test_wb.py index 1b9fe975d7ea1..6a8a792393159 100644 --- a/pandas/io/tests/test_wb.py +++ b/pandas/io/tests/test_wb.py @@ -15,7 +15,7 @@ class TestWB(tm.TestCase): @slow @network def test_wdi_search(self): - raise nose.SkipTest + #raise nose.SkipTest expected = {u('id'): {2634: u('GDPPCKD'), 4649: u('NY.GDP.PCAP.KD'), @@ -35,7 +35,7 @@ def test_wdi_search(self): @slow @network def test_wdi_download(self): - raise nose.SkipTest + #raise nose.SkipTest expected = {'GDPPCKN': {(u('United States'), u('2003')): u('40800.0735367688'), (u('Canada'), u('2004')): u('37857.1261134552'), (u('United States'), u('2005')): u('42714.8594790102'), (u('Canada'), u('2003')): u('37081.4575704003'), (u('United States'), u('2004')): u('41826.1728310667'), (u('Mexico'), u('2003')): u('72720.0691255285'), (u('Mexico'), u('2004')): u('74751.6003347038'), (u('Mexico'), u('2005')): u('76200.2154469437'), (u('Canada'), u('2005')): u('38617.4563629611')}, 'GDPPCKD': {(u('United States'), u('2003')): u('40800.0735367688'), (u('Canada'), u('2004')): u('34397.055116118'), (u('United States'), u('2005')): u('42714.8594790102'), (u('Canada'), u('2003')): u('33692.2812368928'), (u('United States'), u('2004')): u('41826.1728310667'), (u('Mexico'), u('2003')): u('7608.43848670658'), (u('Mexico'), u('2004')): u('7820.99026814334'), (u('Mexico'), u('2005')): u('7972.55364129367'), (u('Canada'), u('2005')): u('35087.8925933298')}} expected = pandas.DataFrame(expected) @@ -47,7 +47,7 @@ def test_wdi_download(self): @slow @network def test_wdi_get_countries(self): - raise nose.SkipTest + #raise nose.SkipTest result = get_countries() assert_equal(result[-1:].name, 'Zimbabwe') From e60ddfe92a73b050896346acd2d7498a1a703fad Mon Sep 17 00:00:00 2001 From: y-p Date: Sat, 25 Jan 2014 03:57:40 +0200 Subject: [PATCH 4/8] DOC/BLD: ipython_directive cleanups --- doc/sphinxext/ipython_directive.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/doc/sphinxext/ipython_directive.py b/doc/sphinxext/ipython_directive.py index 6bdb601897ca4..e6f6f13c6cd26 100644 --- a/doc/sphinxext/ipython_directive.py +++ b/doc/sphinxext/ipython_directive.py @@ -447,15 +447,11 @@ def process_input(self, data, input_prompt, lineno): # context information filename = self.state.document.current_source lineno = self.state.document.current_line - try: - lineno -= 1 - except: - pass # output any exceptions raised during execution to stdout # unless :okexcept: has been specified. if not is_okexcept and "Traceback" in output: - s = "\nException in %s at line %s:\n" % (filename, lineno) + s = "\nException in %s at block ending on line %s\n" % (filename, lineno) sys.stdout.write('\n\n>>>'+'-'*73) sys.stdout.write(s) sys.stdout.write(output) @@ -464,15 +460,16 @@ def process_input(self, data, input_prompt, lineno): # output any warning raised during execution to stdout # unless :okwarning: has been specified. if not is_okwarning: + import textwrap for w in ws: - s = "\nWarning raised in %s at line %s:\n" % (filename, lineno) + s = "\nWarning in %s at block ending on line %s\n" % (filename, lineno) sys.stdout.write('\n\n>>>'+'-'*73) sys.stdout.write(s) sys.stdout.write('-'*76+'\n') s=warnings.formatwarning(w.message, w.category, w.filename, w.lineno, w.line) - sys.stdout.write(s) - sys.stdout.write('\n<<<' + '-'*73+'\n\n') + sys.stdout.write('\n'.join(textwrap.wrap(s,80))) + sys.stdout.write('\n<<<' + '-'*73+'\n') self.cout.truncate(0) return (ret, input_lines, output, is_doctest, decorator, image_file, From 622cd883154af3a90879616be3cf80f78006aa47 Mon Sep 17 00:00:00 2001 From: Clark Fitzgerald Date: Sun, 19 Jan 2014 21:14:22 -0800 Subject: [PATCH 5/8] changed get_countries URL --- pandas/io/wb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/wb.py b/pandas/io/wb.py index 362b7b192f746..d815bb19ec8b8 100644 --- a/pandas/io/wb.py +++ b/pandas/io/wb.py @@ -106,7 +106,7 @@ def _get_data(indicator="NY.GNS.ICTR.GN.ZS", country='US', def get_countries(): '''Query information about countries ''' - url = 'http://api.worldbank.org/countries/all?format=json' + url = 'http://api.worldbank.org/countries/?per_page=1000&format=json' with urlopen(url) as response: data = response.read() data = json.loads(data)[1] From 20beca11aab64c2ded5780996579f58c82e5e681 Mon Sep 17 00:00:00 2001 From: Clark Fitzgerald Date: Wed, 22 Jan 2014 06:21:07 -0800 Subject: [PATCH 6/8] Added test for wb.get_countries --- pandas/io/tests/test_wb.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pandas/io/tests/test_wb.py b/pandas/io/tests/test_wb.py index 9549372823af8..1b9fe975d7ea1 100644 --- a/pandas/io/tests/test_wb.py +++ b/pandas/io/tests/test_wb.py @@ -1,13 +1,15 @@ import nose +from nose.tools import assert_equal import pandas from pandas.compat import u from pandas.util.testing import network from pandas.util.testing import assert_frame_equal from numpy.testing.decorators import slow -from pandas.io.wb import search, download +from pandas.io.wb import search, download, get_countries import pandas.util.testing as tm + class TestWB(tm.TestCase): @slow @@ -30,7 +32,6 @@ def test_wdi_search(self): expected.index = result.index assert_frame_equal(result, expected) - @slow @network def test_wdi_download(self): @@ -43,6 +44,14 @@ def test_wdi_download(self): expected.index = result.index assert_frame_equal(result, pandas.DataFrame(expected)) + @slow + @network + def test_wdi_get_countries(self): + raise nose.SkipTest + + result = get_countries() + assert_equal(result[-1:].name, 'Zimbabwe') + if __name__ == '__main__': nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'], From e298c6fe6b9282855f8e93584b93b518a32c48af Mon Sep 17 00:00:00 2001 From: Clark Fitzgerald Date: Wed, 22 Jan 2014 19:52:34 -0800 Subject: [PATCH 7/8] commented out nose.SkipTest --- pandas/io/tests/test_wb.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/io/tests/test_wb.py b/pandas/io/tests/test_wb.py index 1b9fe975d7ea1..6a8a792393159 100644 --- a/pandas/io/tests/test_wb.py +++ b/pandas/io/tests/test_wb.py @@ -15,7 +15,7 @@ class TestWB(tm.TestCase): @slow @network def test_wdi_search(self): - raise nose.SkipTest + #raise nose.SkipTest expected = {u('id'): {2634: u('GDPPCKD'), 4649: u('NY.GDP.PCAP.KD'), @@ -35,7 +35,7 @@ def test_wdi_search(self): @slow @network def test_wdi_download(self): - raise nose.SkipTest + #raise nose.SkipTest expected = {'GDPPCKN': {(u('United States'), u('2003')): u('40800.0735367688'), (u('Canada'), u('2004')): u('37857.1261134552'), (u('United States'), u('2005')): u('42714.8594790102'), (u('Canada'), u('2003')): u('37081.4575704003'), (u('United States'), u('2004')): u('41826.1728310667'), (u('Mexico'), u('2003')): u('72720.0691255285'), (u('Mexico'), u('2004')): u('74751.6003347038'), (u('Mexico'), u('2005')): u('76200.2154469437'), (u('Canada'), u('2005')): u('38617.4563629611')}, 'GDPPCKD': {(u('United States'), u('2003')): u('40800.0735367688'), (u('Canada'), u('2004')): u('34397.055116118'), (u('United States'), u('2005')): u('42714.8594790102'), (u('Canada'), u('2003')): u('33692.2812368928'), (u('United States'), u('2004')): u('41826.1728310667'), (u('Mexico'), u('2003')): u('7608.43848670658'), (u('Mexico'), u('2004')): u('7820.99026814334'), (u('Mexico'), u('2005')): u('7972.55364129367'), (u('Canada'), u('2005')): u('35087.8925933298')}} expected = pandas.DataFrame(expected) @@ -47,7 +47,7 @@ def test_wdi_download(self): @slow @network def test_wdi_get_countries(self): - raise nose.SkipTest + #raise nose.SkipTest result = get_countries() assert_equal(result[-1:].name, 'Zimbabwe') From 1d1427af12e78d93a9b499e21dd3ee6689f59776 Mon Sep 17 00:00:00 2001 From: Clark Fitzgerald Date: Fri, 24 Jan 2014 19:16:57 -0800 Subject: [PATCH 8/8] documenting --- doc/source/release.rst | 1 + pandas/io/tests/test_wb.py | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index 90e440a80ac1c..0db9023301dab 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -102,6 +102,7 @@ Improvements to existing features Bug Fixes ~~~~~~~~~ + - Bug in ``io.wb.get_countries`` not including all countries (:issue:`6008`) - Bug in Series replace with timestamp dict (:issue:`5797`) - read_csv/read_table now respects the `prefix` kwarg (:issue:`5732`). - Bug in selection with missing values via ``.ix`` from a duplicate indexed DataFrame failing (:issue:`5835`) diff --git a/pandas/io/tests/test_wb.py b/pandas/io/tests/test_wb.py index 6a8a792393159..da0efacacc7de 100644 --- a/pandas/io/tests/test_wb.py +++ b/pandas/io/tests/test_wb.py @@ -15,7 +15,6 @@ class TestWB(tm.TestCase): @slow @network def test_wdi_search(self): - #raise nose.SkipTest expected = {u('id'): {2634: u('GDPPCKD'), 4649: u('NY.GDP.PCAP.KD'), @@ -35,7 +34,6 @@ def test_wdi_search(self): @slow @network def test_wdi_download(self): - #raise nose.SkipTest expected = {'GDPPCKN': {(u('United States'), u('2003')): u('40800.0735367688'), (u('Canada'), u('2004')): u('37857.1261134552'), (u('United States'), u('2005')): u('42714.8594790102'), (u('Canada'), u('2003')): u('37081.4575704003'), (u('United States'), u('2004')): u('41826.1728310667'), (u('Mexico'), u('2003')): u('72720.0691255285'), (u('Mexico'), u('2004')): u('74751.6003347038'), (u('Mexico'), u('2005')): u('76200.2154469437'), (u('Canada'), u('2005')): u('38617.4563629611')}, 'GDPPCKD': {(u('United States'), u('2003')): u('40800.0735367688'), (u('Canada'), u('2004')): u('34397.055116118'), (u('United States'), u('2005')): u('42714.8594790102'), (u('Canada'), u('2003')): u('33692.2812368928'), (u('United States'), u('2004')): u('41826.1728310667'), (u('Mexico'), u('2003')): u('7608.43848670658'), (u('Mexico'), u('2004')): u('7820.99026814334'), (u('Mexico'), u('2005')): u('7972.55364129367'), (u('Canada'), u('2005')): u('35087.8925933298')}} expected = pandas.DataFrame(expected) @@ -47,7 +45,6 @@ def test_wdi_download(self): @slow @network def test_wdi_get_countries(self): - #raise nose.SkipTest result = get_countries() assert_equal(result[-1:].name, 'Zimbabwe')