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.4.tar.gz (24.2 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.4-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: canonical_transformer-1.0.4.tar.gz
  • Upload date:
  • Size: 24.2 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.4.tar.gz
Algorithm Hash digest
SHA256 9717b67195572ab5c7bb00dd45391c3d86c08a97e437a7af032c7c21f38b8692
MD5 88d05d426fbf05a101249e8202b2a2ac
BLAKE2b-256 c52cb76276e8172a4122b580b0c8e9559b503f61d9dc0a8d3426fabb697d7d3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for canonical_transformer-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 98101b4457955e7e5bacf2cb7bfb2f9a1cb9132a7b44caeaf459bc7a43d6b406
MD5 b0f474bb946c7b6475b0189c01e4566a
BLAKE2b-256 7250b1b0dadb3aaa3a663dcd8c371a5f1e7468ce43f62b79cdedf9e1cbc51011

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