marimo
marimo copied to clipboard
New dataframe transform: expanddict
Description
I would like a transform that senses dict like items (having keys) and inserts new column in the dataframe with the keys rewritten in the following format: 'dictitem.keyname', along with the associated values on a row by row basis. At the end, the original item could be dropped.
This would allow all the other dataframe Marimo transforms to be easily used. (See also a request to explode array like items.)
Suggested solution
The transform would allow selection of one or more dict like items. For each of those, for each key, the transform would traverse the dataframe by rows, adding a new column/value pair for each key. The new columns would be named as 'originalcolname.keyname'. At the end, the original column can be dropped.
For example: 'mycol': {'acol': 'acol', 'bcol': 'bcol'} 'mycol': {'acol': 'acol1', 'bcol': 'bcol1'} would become 'acol': 'acol', 'bcol': 'bcol' 'acol': 'acol1', 'bcol1': 'bcol'
and 'mycol' would be dropped
Alternative
No response
Additional context
No response