Skip to main content

DataTrade Processing

[!IMPORTANT]
Proyect developent has moved to Codeberg

Overview

This project provides tools for processing trade data for Puerto Rico, integrating various data sources and performing necessary transformations using Polars and Ibis. The project also includes unit tests to ensure the integrity and correctness of data processing functionalities.

Features

  • Import and process trade data from Parquet files.
  • Support for various aggregation types (e.g., total, NAICS, HTS).
  • Flexible handling of different timeframes (e.g., yearly, monthly, quarterly).
  • Unit tests for validating data processing against expected results.
  • The default data storage is SQLite, but can be configured to use PostgreSQL (other databases are not yet supported).

Requirements

  • Python 3.10+
  • polars
  • ibis-framework
  • pytest
  • sqlite3

You can install the required libraries using pip:

pip install polars ibis-framework pytest

Installation

  1. Clone the repository:

    git clone https://github.com/ouslan/jp-imports.git
    cd jp-imports
    
  2. Install the necessary dependencies:

    pip install -r requirements.txt
    # or
    conda env create -f environment.yml
    

Usage

DataTrade Class

The main class for processing trade data is DataTrade. You can initialize it with a SQLite database connection string and then use its methods to insert and process data.

from src.jp_imports.data_process import DataTrade

# Initialize DataTrade
data_trade = DataTrade("sqlite:///path/to/database.sqlite", dev=True)

# Insert data
data_trade.insert_int_jp("path/to/jp_data_sample.parquet", "path/to/code_agr.json")
data_trade.insert_int_org("path/to/org_data_sample.parquet")

# Process data
result_df = data_trade.process_int_jp("yearly", "total", True).to_polars()

However, you can call the DataTrade class directly and will do all the insert and data download steps for you. Example:

from src.jp_imports.data_process import DataTrade

data_trade = DataTrade()
data_trade.process_int_jp("yearly", "total", True)
# or
data_trade.process_int_org("yearly", "total", True)

Running Tests

To run the unit tests, use pytest:

pytest

This will execute all tests defined in the tests directory and report the results.

Directory Structure

datatrade-processing/
├── src/
│   └── jp_imports/
│       |── data_process.py
|       └── data_pull.py
├── test/
│   └── test_inserts/
│       ├── jp_data_sample.parquet
│       ├── org_data_sample.parquet
│       └── jp_results_yearly_total_True.parquet
├── tests/
│   └── test_data_trade.py
└── requirements.txt

License

This project is licensed under the GPL V3 License. See the LICENSE file for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jp_imports-1.6.4.tar.gz (203.2 kB view details)

Uploaded Source

Built Distribution

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

jp_imports-1.6.4-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file jp_imports-1.6.4.tar.gz.

File metadata

  • Download URL: jp_imports-1.6.4.tar.gz
  • Upload date:
  • Size: 203.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for jp_imports-1.6.4.tar.gz
Algorithm Hash digest
SHA256 cc3cb3421ccf85f582c287c11de98d7660022bcf7360686fa307fecb7522f71c
MD5 52ef73a81390f10ba9c855431f6b1a4d
BLAKE2b-256 cba416f4a7f0e39862e59b38ce3354b8e95a4bf1f3a39d0be200b9af0641ae41

See more details on using hashes here.

File details

Details for the file jp_imports-1.6.4-py3-none-any.whl.

File metadata

  • Download URL: jp_imports-1.6.4-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for jp_imports-1.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fa153fc2cae967ae59c6f50291bc9b499b17856d1acab540b05fbcca6945b6f2
MD5 413406bde3625e96f494347b1d5c7ceb
BLAKE2b-256 9343bb81851beb2c53830d9654f739fbc15f292a2e3a526c6f789151931501a5

See more details on using hashes here.

Release history Release notifications | RSS feed

1.8.0

2 files

1.7.5

2 files

1.7.4

2 files

1.7.2

2 files

1.7.1

2 files

1.7.0

2 files

1.6.7

2 files

1.6.6

2 files

1.6.5

2 files

This release

1.6.4 This release

2 files

1.6.3

2 files

1.6.2

2 files

1.6.1

2 files

1.6.0

2 files

1.5.1

2 files

1.5.0

2 files

1.4.1

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page