Skip to main content

A set of functions to calculate Prices Economics statistics.

Project description

What is it?

precon is a Python package that provides a suite of speedy, vectorised functions for implementing common methods in the production of Price Indices. It aims to provide the high-level building blocks for building statistical systems at National Statistical Institutes (NSIs) and other research institutions concerned with creating indices. It has been developed in-house at the Office for National Statistics (ONS) and aims to become the standard library for price index production. This can only be achieved with help from the community, so all contributions are welcome!

Installation

pip install precon

Use

import precon

API

Many functions in the precon package are designed to work with pandas DataFrames or Series that contain only one type of value, with any categorical or descriptive metadata contained within either the index or columns axis. Each component of a statistical operation or equation will usually be within it’s own DataFrame, i.e. prices in one Frame and weights in another. When dealing with time series data, the functions expect one axis to contain only the datetime index. Where a function accepts more than one input DataFrame, they will need to share the same index values so that pandas can match up the components that the programmer wants to process together. Processing values using this matrix format approach allows the functions to take advantage of powerful pandas/numpy vectorised methods.

It is not always necessary that the time series period frequencies match up if the values in one DataFrame do not change over the given period frequency in another DataFrame, as the functions will resample to the smaller period frequency and fill forward the values.

Check the docs for detailed guidance on each function and its parameters.

Features

  • Calculate fixed-base price indices using common index methods.

  • Combine or aggregate lower-level indices to create higher-level indices.

  • Chain fixed-base indices together for a continuous time series.

  • Re-reference indices to start from a different time period.

  • Calculate contributions to higher-level indices from each of the component indices.

  • Impute new base prices over a time series.

  • Uprating values by index movements.

  • Rounding weight values with adjustment to ensure the sum doesn’t change.

  • Stat compiler functions to quickly produce common sets of statistics.

Dependencies

Contributing to precon

See CONTRIBUTING.rst

Documentation

The full documentation is at http://precon.rtfd.org.

History

0.6.1 (2020-10-15)

  • Bug fix: fixed broken API definition.

  • Updated README to reflect new installation instructions.

0.6.0 (2020-10-14)

  • Added functionality for base_price_imputation function accepting
    the to_impute argument.
  • Aggregation function now works with mean or geometric mean depending
    on method argument.
  • The function calculate_index introduced offering various
    different index methods.
  • The index_calculator pipeline function offers an end-to-end
    pipeline for calculating indices with optional base price imputation.

0.5.1 (2020-06-09)

  • Bug fix in uprate function occuring in Q4 periods.

0.5.0 (2020-06-09)

  • Removed the prorate function.

0.4.0 (2020-06-05)

  • Introduced new function uprate and get_uprating_factors for price uprating.

0.3.5 (2020-05-22)

  • Bug fix

0.3.4 (2020-05-22)

  • Introduced improvements to round_and_adjust_weights to work with Series
    and on any axis of a DataFrame with the axis option.

0.3.3 (2020-05-15)

  • Rolled back set_first_period in chaining as it introduced a bug.

0.3.2 (2020-05-15)

  • Bug fix: included flip_axis function in helpers.

0.3.1 (2020-05-15)

  • Modified aggregation function to work with weight Series and different axes.

  • Changed set_jans in chaining to set_first_period_to_100 to work with
    quarterly series.

0.3.0 (2020-05-14)

  • Added round_and_adjust_weights function in rounding.py.

  • Add set_jans function and improved time series validation in chaining to
    make functions more robust.

0.2.0 (2020-03-31)

  • Added create_special_aggregation function.

0.1.1 (2020-03-31)

  • Fixed bug in importing functions in get_stats module.

0.1.0 (2020-01-27)

  • First installable version.

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

precon-0.6.1.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

precon-0.6.1-py2.py3-none-any.whl (32.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file precon-0.6.1.tar.gz.

File metadata

  • Download URL: precon-0.6.1.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for precon-0.6.1.tar.gz
Algorithm Hash digest
SHA256 c9160e8b3e1c7d5ec918acfa5704f79973ce8d6ab46469d6bca207c48510c4fe
MD5 15d03c37ac66161e918d7e00a723363f
BLAKE2b-256 7142a36b7d7b7a5fccdb77b39a5163d102203ce025a25bb2d11272145a9dec52

See more details on using hashes here.

File details

Details for the file precon-0.6.1-py2.py3-none-any.whl.

File metadata

  • Download URL: precon-0.6.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for precon-0.6.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6fcfdaec7012dc242f3e981188879424c5fed592016dff61a98986905c5c3167
MD5 1c66ccc6ecaaf90a2382a02b38f19b0d
BLAKE2b-256 fb2accda9f8296235f3e8118ab9d703e806c28c403aa2539e7c31a05fa9d2001

See more details on using hashes here.

Supported by

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