Skip to main content

Provids easy access to German publically availible regional statistics

Project description

https://img.shields.io/pypi/v/datenguidepy.svg https://img.shields.io/travis/CorrelAid/datenguide-python.svg https://readthedocs.org/projects/datenguidepy/badge/?version=latest

The package provides easy access to German publicly available regional statistics. It does so by providing a wrapper for the GraphQL API of the Datenguide project.

Features

Overview of available statistics and regions:

The package provides DataFrames with the available statistics and regions, which can be queried by the user without having to refer to expert knowledge on regional statistics or the documentation of the underlying GraphQL API

Build and Execute Queries:

The package provides the user an object oriented interface to build queries that fetch certain statistics and return the results as a pandas DataFrame for further analysis.

Quick Start

Install

To use the package install the package (command line):

pip install datenguidepy

Setup query

Within your python file or notebook:

1. Import the package

from datenguidepy import Query

2. Creating a query

  • either for single regions

query = Query.region('01')
  • or for all subregions a region (e.g. all Kommunen in a Bundesland)

query_allregions = Query.allRegions(parent='01')
  • How to get IDs for regions? see below “Get information on fields and meta data”

3. Add statistics (fields)

  • Add statistics you want to get data on

query.add_field('BEV001')
  • How do I find the short name of the statistics? see below “Get information on fields and meta data”

4. Add filters

A field can also be added with filters. E.g. you can specify, that only data from a specific year shall be returned.

query.add_field('BEV001', args={year:'2017'})
5. Add subfield

A set of default subfields are defined for all statistics (year, value, source). If additional fields shall be returned, they can be specified as a field argument.

query.add_field('BEV001', field=['GES'])
6. Get results

Get the results as a Pandas DataFrame

df = query.results()

Get information on fields and meta data

Get information on region ids

from datenguidepy import get_all_regions

get_all_regions()

Use pandas query() functionality to get specific regions. E.g., if you want to get all IDs on “Bundeländer” use. For more information on “nuts” levels see Wikipedia.

get_all_regions().query("level == 'nuts1'")

Get information on statistic shortnames

from datenguidepy import get_statistics

get_statistics()

Get information on single fields

You can further information about description, possible arguments, fields and enum values on a field you added to a query.

query = Query.region("01")
field = query.add_field("BEV001")
field.get_info()

Further information

For detailed examples see the notebooks within the use_case folder.

For a detailed documentation of all statistics and fields see the Datenguide API.

Credits

All this builds on the great work of Datenguide and their GraphQL API datenguide/datenguide-api

The data is retrieved via the Datenguide API from the “Statistische Ämter des Bundes und der Länder”. Data being used via this package has to be credited according to the “Datenlizenz Deutschland – Namensnennung – Version 2.0”.

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2019-10-07)

  • First release on PyPI.

0.1.1 (2019-10-09)

  • Cleanup of the first release regarding naming, authors and docs.

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

datenguidepy-0.1.2.tar.gz (151.8 kB view details)

Uploaded Source

File details

Details for the file datenguidepy-0.1.2.tar.gz.

File metadata

  • Download URL: datenguidepy-0.1.2.tar.gz
  • Upload date:
  • Size: 151.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4+

File hashes

Hashes for datenguidepy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e7c4a527d558760d1ec42d042802843089a435735131574763c7bed7b844a02f
MD5 aa7c6fa9ffcfaabc92aa070e709f2049
BLAKE2b-256 b4461ab1ae814ea108c73af90f5285773ddf39f3a8a2b58201dabb520f0301b5

See more details on using hashes here.

Supported by

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