marimo icon indicating copy to clipboard operation
marimo copied to clipboard

New dataframe transform: expanddict

Open jbower1950 opened this issue 1 year ago • 0 comments

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

jbower1950 avatar Aug 11 '24 18:08 jbower1950