Read-only mirror of https://github.com/dscc-admin-ch/metadata-auto — Data Science Competence Center DSCC. Issues & pull requests at the source.
  • Jupyter Notebook 62.9%
  • Python 32.1%
  • Dockerfile 4.6%
  • Shell 0.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Pauline Maury Laribière b3550e3559 renkulab.io: migrate to latest version for renku 2.9.2
renku-transaction: ddcf4350d0a04a1aaf693bf2159ebbd8
2024-04-25 09:24:02 +00:00
.renku renkulab.io: migrate to latest version for renku 2.9.2 2024-04-25 09:24:02 +00:00
fso_metadata Fix parameters initialisation and import of contants 2023-01-20 13:10:50 +00:00
test adding unit test 2021-10-28 10:12:07 +00:00
.dockerignore service: renku init -n "Meatadata Auto" -s "https://github.com/SwissDataScienceCenter/renku-proje... 2021-10-14 14:34:20 +00:00
.gitignore adding unit test 2021-10-28 10:12:07 +00:00
.gitlab-ci.yml service: renku init -n "Meatadata Auto" -s "https://github.com/SwissDataScienceCenter/renku-proje... 2021-10-14 14:34:20 +00:00
.renkulfsignore service: renku init -n "Meatadata Auto" -s "https://github.com/SwissDataScienceCenter/renku-proje... 2021-10-14 14:34:20 +00:00
Dockerfile renkulab.io: migrate to latest version for renku 2.9.2 2024-04-25 09:24:02 +00:00
environment.yml service: renku init -n "Meatadata Auto" -s "https://github.com/SwissDataScienceCenter/renku-proje... 2021-10-14 14:34:20 +00:00
examples.ipynb environment update 2022-03-11 13:53:37 +00:00
LICENSE.txt adding files to make a library 2021-10-15 13:17:53 +00:00
make_library adding unit test 2021-10-28 10:12:07 +00:00
README.md environment update and doc 2022-03-11 13:54:39 +00:00
requirements.txt blake formatting 2021-10-21 12:00:39 +00:00
setup.cfg adding files to make a library 2021-10-15 13:17:53 +00:00
setup.py Push new pypi version 2023-01-24 12:27:37 +00:00

Metadata Auto

Introduction

This repository aims to simplify the access to the Swiss Federal Statistical Office metadata. Following the implementation in the interoperability platform and the SIS portal, the APIs are made available here in python. This public library is made available for the internal FSO staff, the federal administration and for external actors.

Installation

You can install the library with

pip install fso_metadata

then at the beginning of your python script, you will need to

import fso_metadata

Functionnalities

Based on the metadata that you want, you will call certain functions and parameters. In the first part, we describe the API available from everywhere, then we describe the API available only from within the confederation network.

Available everywhere with the interoperability plateform (i14y)

Codelists

  1. Export a codelist based on an identifier
response = get_codelist(
    identifier, 
    export_format="SDMX-ML", 
    version_format=2.1, 
    annotations=False
)
Parameters:
    - identifier (str): the codelist's identifier
    - environment (str, default="PRD"): environment to call
        Available are 'PRD', 'ABN', 'TEST', 'QA' and 'DEV'.
    - export_format (str, default="SDMX-ML"): the export's format. 
        Available are CSV, XLSX, SDMX-ML or SDMX-JSON.
    - version_format (float, default=2.1): the export format's version 
        (2.0 or 2.1 when format is SDMX-ML).
    - annotations (bool, default=False): flag to include annotations
Returns:
    - response (pd.DataFrame or dict) based on the export format
        - a pd.DataFrame if export_format was CSV or XLSX
        - a dictionnary if export_format was SDMX-ML or SDMX-JSON.

Nomenclatures

  1. Export one level of a nomenclature
response = get_nomenclature_one_level(
    identifier, 
    level_number, 
    filters={}, 
    language='fr', 
    annotations=False
)
Parameters:
    - identifier (str): nomenclature's identifier
    - environment (str, default="PRD"): environment to call
        Available are 'PRD', 'ABN', 'TEST', 'QA' and 'DEV'.
    - level_number (int): level to export
    - filter (default={}): additionnal filters
    - language (str, default='fr'): response data's language 
        Available are 'fr', 'de', 'it', 'en'.
    - annotations (bool, default=False): flag to include annotations
Returns:
    - response (pd.DataFrame): dataframe with 3 columns 
        (Code, Parent and Name in the selected language)
  1. Export multiple levels of a nomenclature (from level_from to level_to)
response = get_nomenclature_multiple_levels(
    identifier, 
    level_from, 
    level_to, 
    filters={}, 
    language='fr', 
    annotations=False
)
Parameters:
    - identifier (str): nomenclature's identifier
    - environment (str, default="PRD"): environment to call
        Available are 'PRD', 'ABN', 'TEST', 'QA' and 'DEV'.
    - level_from (int): the 1st level to include
    - level_to (int): the last level to include
    - filter (default={}): additionnal filters
    - language (str, default='fr'): response data's language 
        Available are 'fr', 'de', 'it', 'en'.
    - annotations (bool, default=False): flag to include annotations
    - post_processing (bool, default=False): flag to post-process
Returns:
    - response (pd.DataFrame): dataframe columns from `level_from` to `level_to` codes

As the APIs continue to be implemented, further functionnalities will be added.

Background

All the APIs made available in this library are also documented in Swagger UI should you want to do more experiments through a UI. See here for APIs of the interoperability platform (public).

Example

Examples for each API are provided in the notebook examples.ipynb.