All Projects → J535D165 → cbsodata

J535D165 / cbsodata

Licence: MIT license
Unofficial Statistics Netherlands (CBS) opendata API client for Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to cbsodata

nomisr
Access UK official statistics from the Nomis database through R.
Stars: ✭ 30 (-6.25%)
Mutual labels:  census-data, national-statistics
Idra
Idra - Open Data Federation Platform
Stars: ✭ 15 (-53.12%)
Mutual labels:  open-data
company-introduction-jp
日本の会社紹介スライドのまとめです。
Stars: ✭ 49 (+53.13%)
Mutual labels:  open-data
cbsodataR
Statistics Netherlands (CBS) OpenData API Client for R
Stars: ✭ 27 (-15.62%)
Mutual labels:  census-data
Ro-dou
Gerador de DAGs no Airflow para fazer clipping do Diário Oficial da União.
Stars: ✭ 41 (+28.13%)
Mutual labels:  open-data
oeplatform
Repository for the code of the Open Energy Platform (OEP) website. The OEP provides an interface to the Open Energy Family
Stars: ✭ 49 (+53.13%)
Mutual labels:  open-data
building-data-genome-project-2
Whole building non-residential hourly energy meter data from the Great Energy Predictor III competition
Stars: ✭ 112 (+250%)
Mutual labels:  open-data
disaster-crawler
Data sources from Kimono currently unavailable
Stars: ✭ 13 (-59.37%)
Mutual labels:  open-data
kushner eb5 census
Jared Kushner and his partners used a program meant for job-starved areas to build a luxury skyscraper
Stars: ✭ 49 (+53.13%)
Mutual labels:  census-data
PyCBC-Tutorials
Learn how to use PyCBC to analyze gravitational-wave data and do parameter inference.
Stars: ✭ 91 (+184.38%)
Mutual labels:  open-data
data.world-py
Python package for data.world
Stars: ✭ 98 (+206.25%)
Mutual labels:  open-data
statistics-coded
Catalogue of resources (R/Python/SQL/SAS/Stata/...) to reproduce the results of Eurostat Statistics Explained articles
Stars: ✭ 31 (-3.12%)
Mutual labels:  open-data
data.gouv.fr
Ce dépôt rassemble les tickets techniques qui portent sur data.gouv.fr.
Stars: ✭ 50 (+56.25%)
Mutual labels:  open-data
egov
eGov España - API abierto de acceso a datos púbicos
Stars: ✭ 21 (-34.37%)
Mutual labels:  open-data
pummeler
Utilities to analyze ACS PUMS files, especially for distribution regression / ecological inference
Stars: ✭ 21 (-34.37%)
Mutual labels:  census-data
datapackage-m
Power Query M functions for working with Tabular Data Packages (Frictionless Data) in Power BI and Excel
Stars: ✭ 26 (-18.75%)
Mutual labels:  open-data
DoReMIFaSol
Téléchargement des données sur le site de l'Insee
Stars: ✭ 25 (-21.87%)
Mutual labels:  open-data
pararius-apartment-hunting-dashboard
🏡 A NodeJS server to scrape Pararius listings and show them in a dashboard 🏘️
Stars: ✭ 37 (+15.63%)
Mutual labels:  netherlands
otv2-platform
An overview of the entire Open Traffic v2 platform and its components
Stars: ✭ 89 (+178.13%)
Mutual labels:  open-data
bhamtech
A community-currated collection of tech resources, projects, and other things related for Birmingham, AL
Stars: ✭ 23 (-28.12%)
Mutual labels:  open-data

Statistics Netherlands opendata API client for Python

pypi tests

Retrieve data from the open data interface of Statistics Netherlands (Centraal Bureau voor de Statistiek) with Python. The data is identical in content to the tables which can be retrieved and downloaded from StatLine. CBS datasets are accessed via the CBS open data portal.

The documentation of this package is found at this page and on readthedocs.io.

R user? Use cbsodataR.

Installation

From PyPi

pip install cbsodata

Usage

Load the package with

>>> import cbsodata

Tables

Statistics Netherlands (CBS) has a large amount of public available data tables (more than 4000 at the moment of writing). Each table is identified by a unique identifier (Identifier).

>>> tables = cbsodata.get_table_list()
>>> print(tables[0])
{'Catalog': 'CBS',
 'ColumnCount': 18,
 'DefaultPresentation': '_la=nl&_si=&_gu=&_ed=LandVanUiteindelijkeZeggenschapUCI&_td=Perioden&graphType=line',
 'DefaultSelection': "$filter=((LandVanUiteindelijkeZeggenschapUCI eq '11111') or (LandVanUiteindelijkeZeggenschapUCI eq '22222')) and (Bedrijfsgrootte eq '10000') and (substringof('JJ',Perioden))&$select=LandVanUiteindelijkeZeggenschapUCI, Bedrijfsgrootte, Perioden, FiscaalJaarloonPerBaan_15",
 'ExplanatoryText': '',
 'Frequency': 'Perjaar',
 'GraphTypes': 'Table,Bar,Line',
 'ID': 0,
 'Identifier': '82010NED',
 'Language': 'nl',
 'MetaDataModified': '2014-02-04T02:00:00',
 'Modified': '2014-02-04T02:00:00',
 'OutputStatus': 'Regulier',
 'Period': '2008 t/m 2011',
 'ReasonDelivery': 'Actualisering',
 'RecordCount': 32,
 'SearchPriority': '2',
 'ShortDescription': '\nDeze tabel bevat informatie over banen en lonen bij bedrijven in Nederland, uitgesplitst naar het land van uiteindelijke zeggenschap van die bedrijven. Hierbij wordt onderscheid gemaakt tussen bedrijven onder Nederlandse zeggenschap en bedrijven onder buitenlandse zeggenschap. In de tabel zijn alleen de bedrijven met werknemers in loondienst meegenomen. De cijfers hebben betrekking op het totale aantal banen bij deze bedrijven en de samenstelling van die banen naar kenmerken van de werknemers (baanstatus, geslacht, leeftijd, herkomst en hoogte van het loon). Ook het gemiddelde fiscale jaarloon per baan is in de tabel te vinden. \n\nGegevens beschikbaar vanaf: 2008 \n\nStatus van de cijfers: \nDe cijfers in deze tabel zijn definitief.\n\nWijzigingen per 4 februari 2014\nDe cijfers van 2011 zijn toegevoegd.\n\nWanneer komen er nieuwe cijfers?\nDe cijfers over 2012 verschijnen in de eerste helft van 2015.\n',
 'ShortTitle': 'Zeggenschap bedrijven; banen, grootte',
 'Source': 'CBS.',
 'Summary': 'Banen en lonen van werknemers bij bedrijven in Nederland\nnaar land van uiteindelijke zeggenschap en bedrijfsgrootte',
 'SummaryAndLinks': 'Banen en lonen van werknemers bij bedrijven in Nederland<br />naar land van uiteindelijke zeggenschap en bedrijfsgrootte<br /><a href="http://opendata.cbs.nl/ODataApi/OData/82010NED">http://opendata.cbs.nl/ODataApi/OData/82010NED</a><br /><a href="http://opendata.cbs.nl/ODataFeed/OData/82010NED">http://opendata.cbs.nl/ODataFeed/OData/82010NED</a>',
 'Title': 'Zeggenschap bedrijven in Nederland; banen en lonen, bedrijfsgrootte',
 'Updated': '2014-02-04T02:00:00'}

Info

Get information about a table with the get_info function.

>>> info = cbsodata.get_info('82070ENG') # Returns a dict with info
>>> info['Title']
'Caribbean Netherlands; employed labour force characteristics 2012'
>>> info['Modified']
'2013-11-28T15:00:00'

Data

The function you are looking for!! The function get_data returns a list of dicts with the table data.

>>> data = cbsodata.get_data('82070ENG')
[{'CaribbeanNetherlands': 'Bonaire',
  'EmployedLabourForceInternatDef_1': 8837,
  'EmployedLabourForceNationalDef_2': 8559,
  'Gender': 'Total male and female',
  'ID': 0,
  'Periods': '2012',
  'PersonalCharacteristics': 'Total personal characteristics'},
 {'CaribbeanNetherlands': 'St. Eustatius',
  'EmployedLabourForceInternatDef_1': 2099,
  'EmployedLabourForceNationalDef_2': 1940,
  'Gender': 'Total male and female',
  'ID': 1,
  'Periods': '2012',
  'PersonalCharacteristics': 'Total personal characteristics'},
 {'CaribbeanNetherlands': 'Saba',
  'EmployedLabourForceInternatDef_1': 1045,
  'EmployedLabourForceNationalDef_2': 971,
  'Gender': 'Total male and female',
  'ID': 2,
  'Periods': '2012',
  'PersonalCharacteristics': 'Total personal characteristics'},
 # ...
]

The keyword argument dir can be used to download the data directly to your file system.

>>> data = cbsodata.get_data('82070ENG', dir="dir_to_save_data")

Catalogs (dataderden)

There are multiple ways to retrieve data from catalogs other than 'opendata.cbs.nl'. The code below shows 3 different ways to retrieve data from the catalog 'dataderden.cbs.nl' (known from Iv3).

On module level.

cbsodata.options.catalog_url = 'dataderden.cbs.nl'
# list tables
cbsodata.get_table_list()
# get dataset 47003NED
cbsodata.get_data('47003NED')

With context managers.

with cbsodata.catalog('dataderden.cbs.nl'):
    # list tables
    cbsodata.get_table_list()
    # get dataset 47003NED
    cbsodata.get_data('47003NED')

As a function argument.

# list tables
cbsodata.get_table_list(catalog_url='dataderden.cbs.nl')
# get dataset 47003NED
cbsodata.get_data('47003NED', catalog_url='dataderden.cbs.nl')

Pandas users

The package works well with Pandas. Convert the result easily into a pandas DataFrame with the code below.

>>> data = pandas.DataFrame(cbsodata.get_data('82070ENG'))
>>> data.head()

The list of tables can be turned into a pandas DataFrame as well.

>>> tables = pandas.DataFrame(cbsodata.get_table_list())
>>> tables.head()

Command Line Interface

This library ships with a Command Line Interface (CLI).

> cbsodata -h
usage: cbsodata [-h] [--version] [subcommand]

CBS Open Data: Command Line Interface

positional arguments:
  subcommand  the subcommand (one of 'data', 'info', 'list')

optional arguments:
  -h, --help  show this help message and exit
  --version   show the package version

Download data:

> cbsodata data 82010NED

Retrieve table information:

> cbsodata info 82010NED

Retrieve a list with all tables:

> cbsodata list

Export data

Use the flag -o to load data to a file (JSON lines).

> cbsodata data 82010NED -o table_82010NED.jl
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].