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 → C≡A → C → B - Round-trip Identity:
T⁻¹ ∘ T(x) = xfor all supported types - Transformation Algebra: Composition, associativity, identity supported
Supported Formats
pandas.DataFrame↔dict↔CSV↔JSON- 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
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 canonical_transformer-1.0.3.tar.gz.
File metadata
- Download URL: canonical_transformer-1.0.3.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a5897d9075e078692e9050800520aab0f22d78a81c91fbdcab3b1e230cd4f93
|
|
| MD5 |
099142af4d525249143d8e8c77de3ab3
|
|
| BLAKE2b-256 |
006b5ab3c68b1247fa7944cee01b8a2ee0674346ba51f0041ba81ac7292b9237
|
File details
Details for the file canonical_transformer-1.0.3-py3-none-any.whl.
File metadata
- Download URL: canonical_transformer-1.0.3-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7589495633d0116c54bb363d2c75d9eeea59b4acfb48b36967a6a89f205661db
|
|
| MD5 |
24a4813ef332e2cebe159f86ff0ced51
|
|
| BLAKE2b-256 |
ca9e16e3fc1af2dfacda2f0ac409b3209b17f697c809b81747bb9498dcd68414
|