Cofog
Project description
Cofog
Introduction
Classification of the Functions of Government (COFOG) is a classification defined by the United Nations Statistics Division. Its purpose is to "classify the purpose of transactions such as outlays on final consumption expenditure, intermediate consumption, gross capital formation and capital and current transfers, by general government" (from home page).
This intention of this package is to serve a convenient way of parsing and interfacing with the classifications.
Data
Data was sourced from the UN's classifications on economic statistics page and parsed into a dictionary that can be found in src/cofog/data.py
.
Features
- Provides the
COFOG
class to represent a Classification of Functions of Government. - Validate
COFOG
codes through Regular Expressions and presence in the data. - Lookup descriptions from codes.
- Traverse the levels of any given code, with the ability to set a lower level without forgetting the original level.
Requirements
- Python >=3.8
- Click >=8.0.1
Installation
You can install Cofog via pip from PyPI:
$ pip install cofog
Usage
Please see the usage page in the docs for full details.
Get started by initialising a new COFOG
object with a code. These can be either specified as strings (with and without dots) or integers.
from cofog import COFOG
cofog = COFOG("04.3.6")
# or any of the following
COFOG("0436")
COFOG("436")
COFOG(436)
You can then access the code's description as well as set it to lower level codes.
print(cofog.description)
# Non-electric energy (CS)
print(cofog.level)
# 3
cofog.set_level(2)
print(cofog.code)
# 04.3
print(cofog.description)
# Fuel and energy
You can also get parent and children codes of any valid code.
print(cofog.get_parent_code())
# 04.3
print(COFOG("07.3").get_children_codes())
# ["07.3.1", "07.3.2", "07.3.3", "07.3.4"]
Contributing
Contributions are very welcome. To learn more, see the Contributor Guide.
License
Distributed under the terms of the MIT license, Cofog is free and open source software.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Credits
This project was heavily inspired by @ellsphillips's govsic package.
This project was generated from @cjolowicz's Hypermodern Python Cookiecutter template.
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
File details
Details for the file cofog-2.0.0.tar.gz
.
File metadata
- Download URL: cofog-2.0.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e27c8e489e3a0897b842669f1e57cbb17719ad42b1baeed92150b56f0d5ca47 |
|
MD5 | 77c88620e29eb752063b4e057530436f |
|
BLAKE2b-256 | c1e3b9b3fe8992e5d493e87b33abf565428d60a59e1e080e501e59435f543a49 |
File details
Details for the file cofog-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: cofog-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4504635a3a18937237bd1940549db58152c00aa7ab0e6907eff411c30629ba23 |
|
MD5 | 1410a1dd9e01ae788c3867620c4addc0 |
|
BLAKE2b-256 | a8b2534bc207481eae811705eb4e3241a13b7d48a9b9b06841f1f535dc4715a3 |