Skip to main content

DRB Eurostat implementation

Project description

EurostatNode Implementation

This drb-impl-eurostat module implements access to Eurostat data with DRB data model.

Eurostat Factory

The module implements the basic factory model defined in DRB in its node resolver. Based on the python entry point mechanism, this module can be dynamically imported into applications.

The entry point group reference is drb.impl.
The implementation name is eurostat.
The factory class is encoded into drb_impl_eurostat.drb_impl_eurostat.

The Eurostat factory creates a DrbEurostatServiceNode if called with the path 'eurostat://' or DrbEurostatDateNode if a dataset or tables code is given in the path 'eurostat://{code}'.

Nodes

DrbEurostatServiceNode

Represent a node for browsing Eurostat data. Its attribute tables contain the list of all the available dataset and tables in the eurostat service. Its children is a list of DrbEurostatDataNode that can be browsed by dataset or table code. This node has no implementations.

DrbEurostatDataNode

Represent an Eurostat dataset or table. Its attribute "columns" contain the list of the data available in this dataset or table. Its children is a list of DrbEurostatRowNode that can be browsed only by its index in the table. A panda DataFrame representation is available using the get_impl(panda.core.frame.DataFrame) method

DrbEurostatRowNode

Represent a single row of an eurostat dataset or table. Its attribute "columns" contain the list of the data available in this row. Its children is a list of DrbEurostatValueNode that can be browsed by index or name of the column. This node has noimplementations.

DrbEurostatValueNode

Represent a single Eurostat cell value from a dataset or table.

limitations

The current version does not manage child modification and insertion.

Using this module

To include this module into your project, the drb-impl-eurostat module shall be referenced into requirement.txt file, or the following pip line can be run:

pip install drb-impl-eurostat

Examples

This example create a DrbEurostatServiceNode using the DrbEurostatFactory then look for tables containing the word 'crimes' using the attribute of the service:

from drb_impl_eurostat import DrbEurostatFactory

factory = DrbEurostatFactory()
service = factory.create('eurostat://')

tables = service.get_attribute('tables')
search = 'crimes'
for table in tables:
    if search in table[0].lower():
        print(table)

Output :

('Crimes recorded by the police by NUTS 3 regions', 'crim_gen_reg')
('Crimes recorded by the police by metropolitan regions', 'met_crim_gen')
('Crimes recorded by the police by other typologies', 'urt_crim_gen')
('Crimes recorded by the police by by offence category', 'crim_gen')
('Crimes recorded by the police by NUTS 3 regions', 'crim_gen_reg')
('Crimes recorded by the police: homicide in cities', 'crim_hom_city')
('Crimes recorded by the police (1950-2000)', 'crim_hist')

We can get the table we want using its code and get a pandas' DataFrame representation

from pandas.core.frame import DataFrame
from drb_impl_eurostat import DrbEurostatFactory

code = 'crim_gen_reg'
factory = DrbEurostatFactory()
service = factory.create('eurostat://')
table = service[code]
print(table.get_impl(DataFrame))

We can also put the code direcly in the path given to the factory

from pandas.core.frame import DataFrame
from drb_impl_eurostat import DrbEurostatFactory

code = 'crim_gen_reg'
factory = DrbEurostatFactory()
table = factory.create('eurostat://' + code)
print(table.get_impl(DataFrame))

Output:

     unit        iccs geo\time   2010    2009   2008
0      NR    ICCS0101       AT   56.0    43.0   46.0
1      NR    ICCS0101      AT1   33.0    23.0   21.0
2      NR    ICCS0101     AT11    5.0     0.0    2.0
3      NR    ICCS0101     AT12   11.0     4.0    4.0
4      NR    ICCS0101     AT13   17.0    19.0   15.0
...   ...         ...      ...    ...     ...    ...
5581   NR  ICCS050211    UKN01  843.0  1025.0  987.0
5582   NR  ICCS050211    UKN02  434.0   443.0  476.0
5583   NR  ICCS050211    UKN03  454.0   525.0  549.0
5584   NR  ICCS050211    UKN04  358.0   340.0  336.0
5585   NR  ICCS050211    UKN05  630.0   643.0  608.0

[5586 rows x 6 columns]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drb-impl-eurostat-1.0.0.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

drb_impl_eurostat-1.0.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file drb-impl-eurostat-1.0.0.tar.gz.

File metadata

  • Download URL: drb-impl-eurostat-1.0.0.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.12.0 pkginfo/1.8.3 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.8.13

File hashes

Hashes for drb-impl-eurostat-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b58535872ae2ec5aec7baf935087e95fc1a436160687e8bace2a1b640738e390
MD5 be2b4d06aeb4148159363d038b9e1688
BLAKE2b-256 6d4701a7155e85e23707cc1d66b115e2913e530322d450dc8d1f333a5ac636e0

See more details on using hashes here.

File details

Details for the file drb_impl_eurostat-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: drb_impl_eurostat-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.12.0 pkginfo/1.8.3 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.8.13

File hashes

Hashes for drb_impl_eurostat-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72841ac4bd5d1ee704ba062e71cb95bafe292c0389848263e7a3d4acc9579012
MD5 c01c1f892a8f7fb944b0dbc88541ec3f
BLAKE2b-256 84de92d2c9bced4321612ba4b56724982f999c4df5101cc4d12b77827ff59c3b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page