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.1.tar.gz (21.5 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.1-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: canonical_transformer-1.0.1.tar.gz
  • Upload date:
  • Size: 21.5 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.1.tar.gz
Algorithm Hash digest
SHA256 6ba9fe20986a7cd6fa4cd2b6643010f7da354f70fab5e36f6f91c1ac7d76d0f4
MD5 4790393b5fc2e3c6bea09de543f9e340
BLAKE2b-256 f7b74a43028849955a45f6be3a6f232dd3a588cbfb3047692b8f63811e84d1ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for canonical_transformer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e7b0af4df0f717ce40dac74c3ffa33ec903f65f2e8a06dab3aa71df28641f3e4
MD5 fb5a84f9594749360089f6bef5d8c249
BLAKE2b-256 e98dae1df1afb50f1cee723bd9d78f32bceaa46b264b8f6c1fcd038398d9d3b4

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