Skip to main content

Suite of tools for macroeconomics analysis

Project description

Macroecon-Tools

A open-source set of tools to assist with macroeconomic work. Extrends the pandas series class into an adjusted timeseries class along with other functionality.

Timeseries and TimeseriesTable Package

This Python package provides two custom classes, Timeseries and TimeseriesTable, for working with time series data and collections of time series. It builds on pandas and numpy to offer additional metadata and advanced operations tailored for macroeconomic analysis of time series


Features

Timeseries Class

The Timeseries class extends pandas.Series and adds the following functionality:

  • Metadata Tracking: Includes attributes like name, source_freq, data_source, and transformations. Automatically appends the applied functions to transformations.

  • Transformation Methods:

    • logdiff: Compute the log difference of the series.
    • diff: Compute the difference over a specified lag.
    • log and log100: Apply logarithmic transformations. (Note: log100 multiplies the log by 100).
  • Aggregation:

    • Aggregate data into different timeframes (e.g., monthly, quarterly) using methods like sum, mean, and lastvalue.
  • Filtering:

    • Apply linear or Hamilton filtering methods.
  • Truncation:

    • Restrict the series to a specific time range.
  • Persistence:

    • Save and load timeseries objects using pickle.
  • Custom Representation:

    • Enhanced string representations for easier inspection.

TimeseriesTable Class

The TimeseriesTable class manages collections of Timeseries objects:

  • Maintains both a dictionary-like structure and a pandas.DataFrame representation.
  • Supports operations like truncation, dropping missing values, and correlation computation.
  • Facilitates saving and loading the entire TimeseriesTable.

-to_latex:

  • Convert the table to a LaTeX table for easy inclusion in reports. -trunc:
  • Truncate the table to a specific time range. -corr:
  • Compute the correlation matrix of the table. -dropna:
  • Drop missing values from the table.

Usage

Timeseries Class

import pandas as pd
from timeseries import Timeseries

# Create a sample Timeseries
data = pd.Series([1 + 0.3 * i for i in range(10)], index=pd.date_range('2024-01-01', periods=10))
ts = Timeseries(data, name="Sample Data", source_freq="daily", data_source="Generated")

# Apply transformations
log_diff = ts.logdiff(1)
truncated = ts.trunc('2024-01-01', '2024-01-04')

TimeseriesTable Class

import pandas as pd
from timeseries import TimeseriesTable, Timeseries

# Create a sample TimeseriesTable
table_data = {
    "series1": Timeseries(pd.Series([1.1, 1.2, 1.3], index=pd.date_range('2024-01-01', periods=3))),
    "series2": Timeseries(pd.Series([2.1, 2.2, 2.3], index=pd.date_range('2024-01-01', periods=3))),
}
table = TimeseriesTable(table_data)

# Perform operations
correlation_matrix = table.corr()
truncated_table = table.trunc('2024-01-01', '2024-01-02')

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

macroecon_tools-1.0.3.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

macroecon_tools-1.0.3-py3-none-any.whl (36.9 kB view details)

Uploaded Python 3

File details

Details for the file macroecon_tools-1.0.3.tar.gz.

File metadata

  • Download URL: macroecon_tools-1.0.3.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/8.5.0 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.32.3 rfc3986/1.5.0 tqdm/4.67.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for macroecon_tools-1.0.3.tar.gz
Algorithm Hash digest
SHA256 500713fcc6577b94aad261b6af0239a758fcf11fe3560976362e1e3e5601bb33
MD5 3712932dcd172acde78e02b39c44ceb6
BLAKE2b-256 979f2bbcdecaf102de2e42e7e42fced1c8f6d96132202e7d54eb3d8d53c4f966

See more details on using hashes here.

File details

Details for the file macroecon_tools-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: macroecon_tools-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 36.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/8.5.0 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.32.3 rfc3986/1.5.0 tqdm/4.67.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for macroecon_tools-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 db2c1c82496bcf513a5a408a5d83f418bb9a59a0e54cdeb885ff0fa5038c4ea0
MD5 501ae75f2cfa919c4600918ff2d97834
BLAKE2b-256 ca24eb21c561c51fb44414d187b1b6f4fb1ff28b44941a47184766407f7d47d3

See more details on using hashes here.

Supported by

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