Skip to main content

A Python module for preserving structural isomorphisms across data transformations, ensuring reversible and type-stable conversions between formats like DataFrame, JSON, and dict.

Project description

Canonical Transformer v1.0.0

A Python module for ensuring structural isomorphism and commutative consistency across data transformations.
This toolkit provides mathematically reversible mappings between pandas.DataFrame, dict, CSV, and JSON formats—preserving data structure, types, and semantics regardless of transformation order.


Features

Isomorphism Guarantees

  • Bijective Mappings: Each transformation has a unique and total inverse
  • Structure Integrity: Index, column types, and ordering are preserved
  • Semantic Equivalence: Original data meaning remains unchanged

Commutative Transformations

  • Order-Invariance: A → B → CA → C → B
  • Round-trip Identity: T⁻¹ ∘ T(x) = x for all supported types
  • Transformation Algebra: Composition, associativity, identity supported

Supported Formats

  • pandas.DataFramedictCSVJSON
  • Full interoperability under unified transformation rules
  • Automatic type casting and structural validation

Core Capabilities

df → dict → csv → json → df      # Exact round-trip equivalence
dict → csv → json → df → dict   # Commutative, isomorphic recovery

These transformations preserve:

  • Data fidelity (values and types)
  • Index and column structure
  • Missing value handling (e.g., NaN ≈ None)

Installation

pip install canonical-transformer==1.0.0

Quick Start

from canonical_transformer import *

df = pd.DataFrame({
    'id': [1, 2, 3],
    'name': ['Alice', 'Bob', 'Charlie'],
    'value': [10.5, -20.3, 30.0]
})

# Commutative round-trip transformation
df2 = map_json_to_df(
           map_csv_to_json(
               map_data_to_csv(
                   map_df_to_data(df), '.', 'out.csv'
               ), '.', 'out.csv'))

assert df.equals(df2)  # True

Mathematical Properties

Isomorphism

  • Injectivity: Each input maps to a unique output
  • Surjectivity: All outputs can be traced back to inputs
  • Bijectivity: Reversible one-to-one mapping

Commutativity

  • Order Independence: Transformations commute
  • Associativity: Grouping doesn’t affect result
  • Identity: T⁻¹ ∘ T = id

Homomorphism

  • Structure Preservation: Index, type, ordering maintained
  • Format Standardization: Consistent formatting across outputs

📦 Requirements

  • Python >= 3.6
  • pandas >= 2.2.3
  • python-dateutil >= 2.9.0
  • pytz >= 2024.2
  • typing_extensions >= 4.12.2

📈 Version History

v1.0.0

  • Structural isomorphism guaranteed
  • Bidirectional reversible transformations
  • Full commutative consistency
  • Format and type standardization

v0.2.x

  • Number formatting utilities
  • Sign-preserving float formatting

👤 Author

June Young Park
AI Systems Architect @ LIFE Asset Management
📧 juneyoungpaak@gmail.com
📍 TWO IFC, Yeouido, Seoul

LIFE Asset Management is a hedge fund management firm that integrates value investing and engagement strategies with quantitative modeling and AI infrastructure.


📖 License

MIT License – see LICENSE file for details.


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

canonical_transformer-1.0.2.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

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

canonical_transformer-1.0.2-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file canonical_transformer-1.0.2.tar.gz.

File metadata

  • Download URL: canonical_transformer-1.0.2.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for canonical_transformer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 59e033722f14662a1999752aa4a38e9bea19aab456c8cfdf17951231c94777bc
MD5 9f5f46572d090255809a87188993320c
BLAKE2b-256 9074801f7bba30141b5d9959dfb1959c9fe2fc50c528e93ec843626fb61f26c8

See more details on using hashes here.

File details

Details for the file canonical_transformer-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for canonical_transformer-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 712d2e9d8ad846d64429fb0d98ada745d91b5e2076b97252105c83cf2ea4b5e6
MD5 43ed27d1df4ab03a089514d2529426fc
BLAKE2b-256 6de7f4148de91ee20459b18d9163ce5407a222a308c87a4fc2fbe4473717aefd

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