1- .. role :: py(code)
2- :language: python
3-
4- .. role :: json(code)
5- :language: json
6-
7-
81Transpose Dictionary
92======================
103|pip | |downloads | |github |
114
12- Simple python package to transpose python dictionaries.
5+ Python package to transpose python dictionaries.
136
14- Multilevel dictionaries can be viewed as projections of sparse n-dimensional matrices: as such, you can transpose them on any of their axes.
7+ Multilevel dictionaries can be viewed as projections of sparse n-dimensional matrices: as such, you can transpose them on any of their axes.
158
16- This package offers a simple function to do that .
9+ The package provides a function that allows you to transpose a dictionary on any of its axes .
1710
1811Installing the transpose dict package
1912-------------------------------------------
@@ -28,9 +21,9 @@ Basic usage example
2821
2922.. code :: python
3023
31- from transpose_dict import TD # or from transpose_dict import transpose_dict
24+ from transpose_dict import transpose_dict # or from transpose_dict import TD, for brevity
3225
33- test = {
26+ your_dictionary = {
3427 " a" :{
3528 " 0" :{
3629 " I" :[1 ,2 ,3 ],
@@ -48,11 +41,11 @@ Basic usage example
4841 }
4942 }
5043
51- TD(test, 0 ) # The given dictionary does not change
44+ transpose_dict(your_dictionary, axis = 0 ) # The given dictionary does not change
5245 # > {"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]}}}
53- TD(test, 1 ) # The new main axis is the one with ("0", "1")
46+ transpose_dict(your_dictionary, axis = 1 ) # The new main axis is the one with ("0", "1")
5447 # > {"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]}}}
55- TD(test, 2 ) # The new main axis is the one with ("I", "II", "III")
48+ transpose_dict(your_dictionary, axis = 2 ) # The new main axis is the one with ("I", "II", "III")
5649 # > {"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]}}}
5750
5851 License
0 commit comments