Coder Social home page Coder Social logo

eurostat-api-client's Introduction

Eurostat API Client (Python)

Use the Eurostat API Client to quickly retrieve json data from Eurostat REST service and convert it to a pandas DataFrame. A simple description of the service can be found here

Installation

Install Eurostat API Client using pip.

pip install eurostatapiclient

Quick start

This example shows how to retrieve a dataset and a pandas dataframe from it.

from eurostatapiclient import EurostatAPIClient

# Choose service version : only 1.0 is currently available
VERSION = '1.0'

# Only json is currently available
FORMAT = 'json'

# Specify language : en, fr, de
LANGUAGE = 'en'

client = EurostatAPIClient(VERSION, FORMAT, LANGUAGE)

# Optionnal : working behing a proxy :
# client.set_proxy({'http':'my.proxy.com/8080', 'https':'my.proxy.com/8080'})

dataset = client.get_dataset('tps00001')
print(dataset.label)

dataframe = dataset.to_dataframe()
print(dataframe.head())

# Add some filters (only mono-filtering is available for now)
params = {
    'geo': 'DE',
}

# Note that some keys may be repeated in eurostat's api
# In that case, you will want to pass params as a list of tuples
# ex. : 
# params = [
#  ('siec', 'TOTAL'),
#  ('precision', '1'),
#  ('unit', 'KTOE'),
#  ('nrg_bal', 'AFC'),
#  ('nrg_bal', 'DL'),
#  ('nrg_bal', 'EXP'),
#  ('nrg_bal', 'FC_E'),
#  ('nrg_bal', 'FEC2020-2030')]
# filtered_dataset = client.get_dataset('nrg_bal_c', params=params)

filtered_dataset = client.get_dataset('tps00001', params=params)
filtered_dataframe = filtered_dataset.to_dataframe()
print(filtered_dataframe.head())

Contributions

Contributions are welcome !

Feel free to suggest modifications/enhancements in the "issues" section, or to create a pull request

eurostat-api-client's People

Contributors

opus-42 avatar tgrandje avatar stefanpetrovic avatar ckauth avatar derevirn avatar jotsif avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.