Skip to main content

🎲 Transpose Dictionary

pip python license downloads github

Python package to transpose Python dictionaries.

Multilevel dictionaries can be viewed as projections of sparse n-dimensional matrices: as such, you can transpose them on any of their axes.

The package provides a function that allows you to transpose a dictionary on any of its axes.

Installing the transpose_dict package

As usual, just use pip as follows:

pip install transpose_dict

Basic usage example

from transpose_dict import transpose_dict # or from transpose_dict import TD, for brevity

your_dictionary = {
    "a" : {
        "0" : {
            "I" : [1, 2, 3],
            "II" : [4, 5, 6]
        }
    },
    "b" : {
        "0" : {
            "I" : [8, 9, 10],
            "II" : [467, 23, 23]
        },
        "1" : {
            "III" : [6, 7, 9]
        }
    }
}

transpose_dict(your_dictionary, axis=0) # The given dictionary does not change
#> {"b": {"0": {"I": [8, 9, 10], "II": [467, 23, 23]}, "1": {"III": [6, 7, 9]}}, "a": {"0": {"I": [1, 2, 3], "II": [4, 5, 6]}}}
transpose_dict(your_dictionary, axis=1) # The new main axis is the one with ("0", "1")
#> {"0": {"a": {"I": [1, 2, 3], "II": [4, 5, 6]}, "b": {"I": [8, 9, 10], "II": [467, 23, 23]}}, "1": {"b": {"III": [6, 7, 9]}}}
transpose_dict(your_dictionary, axis=2) # The new main axis is the one with ("I", "II", "III")
#> {"I": {"a": {"0": [1, 2, 3]}, "b": {"0": [8, 9, 10]}}, "III": {"b": {"1": [6, 7, 9]}}, "II": {"a": {"0": [4, 5, 6]}, "b": {"0": [467, 23, 23]}}}

License

The software is released under the MIT license.

Metadata

Release files for transpose-dict 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for transpose-dict 1.2.1
File Size Uploaded Provenance
transpose_dict-1.2.1.tar.gz 4.6 kB Without provenance Details

Release files / transpose_dict-1.2.1.tar.gz

Download URL transpose_dict-1.2.1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e94695b6dae9bcc5ef4c2be2df12a0af4be90dfe32e070cb0e8862e1d1dc8f72
BLAKE2b-256 checksum
How to use checksums
268229b46aa2bfd10c714b454efeeed7bbda091d3321650a76a871d8740e7ec9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.9

Security for transpose-dict 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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