A python library for working with the National Institute of Statistics Tempo Online Database.
Project description
tempo.py
A python library for working with the National Institute of Statistics Tempo Online Database. There's also an already existing R package.
🚧 UNDER CONSTRUCTION 🚧
Example usage
from tempo import Node, LeafNode
nodes = Node.get_all()
[print(" " * n.level + n.name) for n in nodes]
# A. STATISTICA SOCIALA
# A.1 POPULATIE SI STRUCTURA DEMOGRAFICA <a href="...">
# 1. POPULATIA REZIDENTA
# 2. POPULATIA DUPA DOMICILIU
# 3. DATE ISTORICE DE POPULATIE (1968 - 1991)
# A.2 MISCAREA NATURALA A POPULATIEI
# ...
nodes = Node.get_all('10')
[print(n.name) for n in nodes]
# 1. POPULATIA REZIDENTA
# 2. POPULATIA DUPA DOMICILIU
# 3. DATE ISTORICE DE POPULATIE (1968 - 1991)
from tempo import eq_lambda
nodes = Node.by_property('level', 0, eq_lambda)
[print(n.name) for n in nodes]
# A. STATISTICA SOCIALA
# B. STATISTICA ECONOMICA
# C. FINANTE
# D. JUSTITIE
# E. MEDIU INCONJURATOR
# F. UTILITATI PUBLICE SI ADMINISTRAREA TERITORIULUI
# H. DEZVOLTARE DURABILA - Tinte 2030
# G. DEZVOLTARE DURABILA - Orizont 2020
leaf = LeafNode.by_code('POP105A')
q = leaf.query(
('Varste si grupe de varsta', ['Total']),
('Sexe', ['Masculin']),
('Medii de rezidenta', ['Rural']),
('Macroregiuni, regiuni de dezvoltare si judete', ['Bihor']),
('Perioade', ['Anul 2016', 'Anul 2017']),
('UM: Numar persoane', ['Numar persoane'])
)
# Varste si grupe de varsta, Sexe, Medii de rezidenta, Macroregiuni regiuni de dezvoltare si judete, Perioade, UM: Numar persoane, Valoare
# Total, Masculin, Rural, Bihor, Anul 2016, Numar persoane, 144439
# Total, Masculin, Rural, Bihor, Anul 2017, Numar persoane, 145335
Concepts
To better understand the concepts of this library it's useful to look at the visual interface of Tempo.
Data organization
All data is organized hierarchically, with all nodes having a specified level, code, parent code, name and more.
API and Data extraction
Extrating data from Tempo is done through a JSON API. Take a look at these URLs for better understanding.
http://statistici.insse.ro:8077/tempo-ins/context/
http://statistici.insse.ro:8077/tempo-ins/context/1010
http://statistici.insse.ro:8077/tempo-ins/matrix/POP105A
Nodes and Leaf Nodes
The differences between nodes and leaf nodes are:
- leaf nodes are located at the bottom of the hierarchy
- leaf nodes are accessed through the
tempo-ins/matrixroute instead of thetempo-ins/contextroute - normal nodes are used just for organization
- leaf nodes actually enable us to query the database
Querying, Dimensions and Options
Querying for data is done by sending a POST request to the URL of the leaf node and providing the following request body:
{
"language": "ro",
"arr": [
[
{
"label": "<option label>",
"nomItemId": 1,
"offset": 1,
"parentId": null
}
],
"..."
],
"matrixName": "<leaf name>",
"matrixDetails": {
"nomJud": 0,
"nomLoc": 0,
"...": "..."
}
}
Dimensions are characteristics of the dataset and each dimension has multiple options. Each element of the arr JSON element corresponds to a dimension and contains the data for the selected options.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tempo_py-0.0.1.tar.gz.
File metadata
- Download URL: tempo_py-0.0.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
494942610eaf615f8012e493d87fde7aed5971342cfbac356d9cab89cc839be3
|
|
| MD5 |
2a2682f9350f9f9fb6ab44917785cbd2
|
|
| BLAKE2b-256 |
59bd8e89b007766f72ca039453f65f42834d98bf82446cf1774fdfc2a2e4a251
|
File details
Details for the file tempo_py-0.0.1-py3-none-any.whl.
File metadata
- Download URL: tempo_py-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24bcf0232a6990f589d26f78f24221f0ca03679287294e315883b5ca1ac5bc73
|
|
| MD5 |
daa3dfb16648343f4bc3daef0a6ad6f1
|
|
| BLAKE2b-256 |
3835b2c0d7c7dceb8cd50a037384b67f2c0973448bb7019762949b75fc2d92c0
|