glom icon indicating copy to clipboard operation
glom copied to clipboard

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

Open kurtbrose opened this issue 5 years ago • 3 comments

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]}])

kurtbrose avatar Dec 18 '19 00:12 kurtbrose

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

mahmoud avatar Dec 18 '19 06:12 mahmoud

the narrow use case was some internal stuff

kurtbrose avatar Dec 18 '19 17:12 kurtbrose

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

kurtbrose avatar Jan 06 '20 21:01 kurtbrose