Skip to content

Instantly share code, notes, and snippets.

@a-recknagel
Created September 18, 2023 09:29
Show Gist options
  • Save a-recknagel/3982399c30a306dc771d6b8b43b2698b to your computer and use it in GitHub Desktop.
Save a-recknagel/3982399c30a306dc771d6b8b43b2698b to your computer and use it in GitHub Desktop.
flat vs nested
nested_representation = {
5: {
"0-100": {
12: {
"new": 0.123,
"old": 0.321,
},
24: {
"new": 0.1234,
"old": 0.4321,
}
},
"100-200": {
12: {
"new": 0.0123,
"old": 0.3210,
},
24: {
"new": 0.01234,
"old": 0.43210,
}
},
},
10: {
"0-100": {
12: {
"new": 0.00123,
"old": 0.32100,
},
24: {
"new": 0.001234,
"old": 0.432100,
}
},
"100-200": {
12: {
"new": 0.000123,
"old": 0.321000,
},
24: {
"new": 0.0001234,
"old": 0.4321000,
}
},
},
}
flat_representation = [
5, "0-100", 12, "new", 0.123,
5, "0-100", 12, "old", 0.321,
5, "0-100", 24, "new", 0.1234,
5, "0-100", 24, "old", 0.4321,
5, "100-200", 12, "new", 0.0123,
5, "100-200", 12, "old", 0.3210,
5, "100-200", 24, "new", 0.01234,
5, "100-200", 24, "old", 0.43210,
10, "0-100", 12, "new", 0.00123,
10, "0-100", 12, "old", 0.32100,
10, "0-100", 24, "new", 0.001234,
10, "0-100", 24, "old", 0.432100,
10, "100-200", 12, "new", 0.000123,
10, "100-200", 12, "old", 0.321000,
10, "100-200", 24, "new", 0.0001234,
10, "100-200", 24, "old", 0.4321000,
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment