Skip to content

Commit 2729a4c

Browse files
econdb - black restyle, and add test
1 parent 7c030f0 commit 2729a4c

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

pandas_datareader/econdb.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ def url(self):
2121
)
2222

2323
def read(self):
24-
""" read one data from specified URL """
25-
params = dict(s.split('=') for s in self.symbols.split('&'))
26-
if 'from' in params:
27-
self.start = pd.to_datetime(params['from'], format='%Y-%m-%d')
28-
if 'to' in params:
29-
self.end = pd.to_datetime(params['to'], format='%Y-%m-%d')
24+
"""read one data from specified URL"""
25+
params = dict(s.split("=") for s in self.symbols.split("&"))
26+
if "from" in params:
27+
self.start = pd.to_datetime(params["from"], format="%Y-%m-%d")
28+
if "to" in params:
29+
self.end = pd.to_datetime(params["to"], format="%Y-%m-%d")
3030

3131
results = self.session.get(self.url).json()["results"]
3232
df = pd.DataFrame({"dates": []}).set_index("dates")
3333

3434
if self._show == "labels":
3535

3636
def show_func(x):
37-
return x[x.find(":") + 1:]
37+
return x[x.find(":") + 1 :]
3838

3939
elif self._show == "codes":
4040

pandas_datareader/tests/test_econdb.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import numpy as np
22
import pandas as pd
3-
from pandas import testing as tm
43
import pytest
4+
from pandas import testing as tm
55

66
from pandas_datareader import data as web
77

88
pytestmark = pytest.mark.stable
99

1010

1111
class TestEcondb(object):
12+
def test_infer_start_end_from_symbols(self):
13+
df = web.DataReader(
14+
(
15+
"dataset=NAMQ_10_GDP&v=Geopolitical entity (reporting)"
16+
"&h=TIME&from=2010-02-01&to=2018-10-01&GEO=[AL,AT,BE,BA,"
17+
"BG,HR,CY,CZ,DK,EE,EA19,FI,FR,DE,EL,HU,IS,IE,IT,XK,LV,LT,"
18+
"LU,MT,ME,NL,MK,NO,PL,PT,RO,RS,SK,SI,ES,SE,CH,TR,UK]"
19+
"&NA_ITEM=[B1GQ]&S_ADJ=[SCA]&UNIT=[CLV10_MNAC]"
20+
),
21+
"econdb",
22+
)
23+
assert df.index[0].year == 2010
24+
assert df.index[-1].year == 2018
25+
1226
def test_get_cdh_e_fos(self):
1327
# EUROSTAT
1428
# Employed doctorate holders in non managerial and non professional
@@ -79,7 +93,6 @@ def test_bls(self):
7993
assert df.loc["2010-05-01"][0] == 217.3
8094

8195
def test_australia_gdp(self):
82-
8396
df = web.DataReader(
8497
"dataset=ABS_GDP&to=2019-09-01&from=1959-09-01&h=TIME&v=Indicator", "econdb"
8598
)

0 commit comments

Comments
 (0)