converts a nested list into a nested dictionary with support for multi-level keys and preserving the order
pip install nested2nested
Tested against Windows 10 / Python 3.10 / Anaconda
Conversion of nested lists to nested dictionaries:
The function provides a convenient way to convert nested lists into nested dictionaries. This can be useful when working with data structures that require a hierarchical representation, such as JSON-like structures or when organizing data in a tree-like format.
Support for multi-level keys:
The function utilizes the MultiKeyIterDict class, which allows the use of multi-level keys in the resulting nested dictionary. This means that each level of the nested list can be represented as a key in the corresponding level of the dictionary.
Preservation of order:
The MultiKeyIterDict class used in the function preserves the order of elements during conversion. This is important when the order of elements in the nested list needs to be maintained in the resulting dictionary.
Flexibility and reusability:
The function is designed to be flexible and can handle nested lists of any depth or structure. It uses a separate module, flatten_any_dict_iterable_or_whatsoever, to flatten the nested list, making it adaptable to various use cases. The MultiKeyIterDict class can also be used independently for other projects involving multi-level dictionaries.
This function can be useful for developers or data analysts working with hierarchical or nested data structures. It simplifies the process of converting nested lists to nested dictionaries and provides flexibility in handling multi-level keys. It can be applied in various domains, including data manipulation, data preprocessing, and working with complex data structures.
from nested2nested import nested_list_to_nested_dict
d = nested_list_to_nested_dict(l=[33, 4, ['baba', 4, ['babx', [[4, 4, 5, 2], 4], 4, 32], 4, 3], 423])
print(d)
{
0: 33,
1: 4,
2: {
0: 'baba',
1: 4,
2: {
0: 'babx',
1: {
0: {
0: 4,
1: 4,
2: 5,
3: 2
},
1: 4
},
2: 4,
3: 32
},
3: 4,
4: 3
},
3: 423
}
Metadata
Release files for nested2nested 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nested2nested-0.10.tar.gz | 4.0 kB | Without provenance | Details for nested2nested-0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nested2nested-0.10-py3-none-any.whl | Python 3 | none | any | Details for nested2nested-0.10-py3-none-any.whl |
Total release size: 10.1 kB
Release files / nested2nested-0.10.tar.gz
| Download URL | nested2nested-0.10.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5048133dcd16338744d286fc27afbc63a6d5cb844701869b11f73a5db7d3299
|
|
BLAKE2b-256 checksum How to use checksums |
125bf8b5944f288f7875c18a4472bd718b69f2e8a1301a0e46c5a9ba1d0fcebb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Release files / nested2nested-0.10-py3-none-any.whl
| Download URL | nested2nested-0.10-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71e1923f66727e0aee62ddb5f2ffc90dd91da1115070414b44ac5f7bbecf4f80
|
|
BLAKE2b-256 checksum How to use checksums |
b9b8b2244f3ebe80b7a8a67fdf0b0baad4ac7366a973b75b8090957037d6059f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Security for nested2nested 0.10
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.