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, andtransformations. Automatically appends the applied functions totransformations. -
Transformation Methods:
logdiff: Compute the log difference of the series.diff: Compute the difference over a specified lag.logandlog100: 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, andlastvalue.
- Aggregate data into different timeframes (e.g., monthly, quarterly) using methods like
-
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.DataFramerepresentation. - 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
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 macroecon_tools-1.0.2.tar.gz.
File metadata
- Download URL: macroecon_tools-1.0.2.tar.gz
- Upload date:
- Size: 50.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4858d35e1e804fff8eb1c0e97778ba4565af48cff2317813d550086754d1fb02
|
|
| MD5 |
51fbe5ae216b3dc4778743143cb81f90
|
|
| BLAKE2b-256 |
3c6906f44e1acf8a32016723e0729a1b0ae9dfeb230b5a61a1a36c9a43d4faa1
|
File details
Details for the file macroecon_tools-1.0.2-py3-none-any.whl.
File metadata
- Download URL: macroecon_tools-1.0.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6529cf754d1caef18c695a8e8864aec58b9a041512c379cfe05ce45ff1191ad
|
|
| MD5 |
e661a14685a87555c2cfab11404f8782
|
|
| BLAKE2b-256 |
1b1be0282afe9f5d03a9862f114822dad7f8fef6932867a1a149bc6f080086fd
|