Skip to content

Commit 4550a05

Browse files
econdb: update and improve documentation
1 parent 65f458f commit 4550a05

File tree

2 files changed

+85
-10
lines changed

2 files changed

+85
-10
lines changed

docs/source/remote_data.rst

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,26 @@ for United States, is as simple as taking the ticker segment from the URL path
305305

306306
.. code-block:: ipython
307307
308-
import os
309-
import pandas_datareader.data as web
308+
In [1]: import os
310309
311-
f = web.DataReader('ticker=RGDPUS', 'econdb')
312-
f.head()
310+
In [2]: import pandas_datareader as pdr
313311
312+
In [3]: f = pdr.get_data_econdb('ticker=RGDPUS')
313+
In [4]: f.head()
314+
Out[4]:
315+
TableName T10106
316+
SeriesCode A191RX
317+
Table Table 1.1.6. Real Gross Domestic Product, Ch...
318+
Series description Gross domestic product
319+
CL_UNIT Level
320+
CL_FREQ Q
321+
Note Table 1.1.6. Real Gross Domestic Product, Ch...
322+
TIME_PERIOD
323+
2018-01-01 18437128
324+
2018-04-01 18565696
325+
2018-07-01 18699748
326+
2018-10-01 18733740
327+
2019-01-01 18835412
314328
315329
The code snippet for exporting the whole dataset, or its filtered down subset,
316330
can be generated by using the Export -> Pandas Python3 functionality
@@ -319,16 +333,47 @@ such as the Eurostat's `GDP and main components <https://www.econdb.com/dataset/
319333

320334
.. code-block:: ipython
321335
322-
import os
323-
import pandas_datareader.data as web
336+
In [1]: import os
324337
325-
df = web.DataReader('dataset=NAMQ_10_GDP&v=Geopolitical entity (reporting)&h=TIME&from=2018-05-01&to=2021-01-01&GEO=[AL,AT,BE,BA,BG,HR,CY,CZ,DK,EE,EA19,FI,FR,DE,EL,HU,IS,IE,IT,XK,LV,LT,LU,MT,ME,NL,MK,NO,PL,PT,RO,RS,SK,SI,ES,SE,CH,TR,UK]&NA_ITEM=[B1GQ]&S_ADJ=[SCA]&UNIT=[CLV10_MNAC]', 'econdb')
326-
df.columns
338+
In [2]: import pandas_datareader as pdr
339+
340+
In [3]: df = pdr.get_data_econdb('dataset=NAMQ_10_GDP&v=Geopolitical entity (reporting)'
341+
'&h=TIME&from=2018-05-01&to=2021-01-01'
342+
'&GEO=[UK,ES,IT,DE,FR,CH,AT]&NA_ITEM=[B1GQ]'
343+
'&S_ADJ=[SCA]&UNIT=[CLV10_MNAC]')
344+
In [4]: df.head()
345+
Out[4]:
346+
Frequency Quarterly ...
347+
Unit of measure Chain linked volumes (2010), million units of national currency ...
348+
Seasonal adjustment Seasonally and calendar adjusted data ...
349+
National accounts indicator (ESA10) Gross domestic product at market prices ...
350+
Geopolitical entity (reporting) Austria ... Switzerland
351+
TIME_PERIOD ...
352+
2018-07-01 83427 ... 181338
353+
2018-10-01 84268 ... 181767
354+
2019-01-01 84919 ... 182039
355+
2019-04-01 84476 ... 182848
356+
2019-07-01 84822 ... 183866
357+
358+
In both cases, metadata for the requested Econdb series or dataset
359+
is in the ``MultiIndex`` columns of the returned ``DataFrame``,
360+
and can be conveniently converted to a ``dict`` as demonstrated below
361+
362+
.. code-block:: ipython
363+
364+
In [5]: meta = df.columns.to_frame().iloc[0].to_dict() # first column, positionally
365+
Out[5]: meta
366+
{'Frequency': 'Quarterly',
367+
'Unit of measure': 'Chain linked volumes (2010), million units of national currency',
368+
'Seasonal adjustment': 'Seasonally and calendar adjusted data',
369+
'National accounts indicator (ESA10)': 'Gross domestic product at market prices',
370+
'Geopolitical entity (reporting)': 'Austria'}
327371
328372
Datasets can be located through Econdb's `search <https://www.econdb.com/search>`__
329373
engine, or discovered by exploring the `tree <https://www.econdb.com/tree/>`__
330374
of available statistical sources.
331375

376+
332377
.. _remote_data.enigma:
333378

334379
Enigma

pandas_datareader/econdb.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,37 @@
44

55

66
class EcondbReader(_BaseReader):
7-
"""Get data for the given name from Econdb."""
7+
"""
8+
Returns DataFrame of historical stock prices from symbol, over date
9+
range, start to end.
10+
11+
.. versionadded:: 0.5.0
12+
13+
Parameters
14+
----------
15+
symbols : string
16+
Can be in two different formats:
17+
1. 'ticker=<code>' for fetching a single series,
18+
where <code> is CPIUS for, e.g. the series at
19+
https://www.econdb.com/series/CPIUS/
20+
2. 'dataset=<dataset>&<params>' for fetching full
21+
or filtered subset of a dataset, like the one at
22+
https://www.econdb.com/dataset/ABS_GDP. After choosing the desired filters,
23+
the correctly formatted query string can be easily generated
24+
from that dataset's page by using the Export function, and choosing Pandas Python3.
25+
start : string, int, date, datetime, Timestamp
26+
Starting date. Parses many different kind of date
27+
representations (e.g., 'JAN-01-2010', '1/1/10', 'Jan, 1, 1980')
28+
end : string, int, date, datetime, Timestamp
29+
Ending date
30+
retry_count : int, default 3
31+
Number of times to retry query request.
32+
pause : int, default 0.1
33+
Time, in seconds, to pause between consecutive queries of chunks. If
34+
single value given for symbol, represents the pause between retries.
35+
session : Session, default None
36+
requests.sessions.Session instance to be used
37+
"""
838

939
_URL = "https://www.econdb.com/api/series/"
1040
_format = None
@@ -53,7 +83,7 @@ def read(self):
5383
if self._show == "labels":
5484

5585
def show_func(x):
56-
return x[x.find(":") + 1 :]
86+
return x[x.find(":") + 1:]
5787

5888
elif self._show == "codes":
5989

0 commit comments

Comments
 (0)