mahmoud / glom

☄️ Python's nested data operator (and CLI), for all your declarative restructuring needs. Got data? Glom it! ☄️
https://glom.readthedocs.io
Other
1.89k stars 61 forks source link

add [{key: k, value: v}] <-> {k: v} example #129

Open kurtbrose opened 4 years ago

kurtbrose commented 4 years ago

either in merge docstring, or cookbook add a doc for exploding / collapsing keys

([{T['key']: 'value'}], Merge())

(T.items(), [{'key': T[0], 'value': T[1]}])
mahmoud commented 4 years ago

Interesting. Is there some API of note that takes the format {'key': <key>, 'value': <value>}?

kurtbrose commented 4 years ago

the narrow use case was some internal stuff

kurtbrose commented 4 years ago

this could be called "Pivot" -- since it is taking row-of-(key + val) and turning it into row-of-(key1 + key2 + ...)

an explicit Pivot() spec that e.g. normalizes the set of keys might be helpful; although I don't have an organic use case for that so not 100% confident it makes sense