pygraphistry icon indicating copy to clipboard operation
pygraphistry copied to clipboard

[FEA] Generalize collapse matchers to accept kv-dict and col list

Open lmeyerov opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe.

Typical cases of .collapse( are acting on a dict ({'type': 'account', 'risk': 'high'}) or a col list (cols=['type'] or cols=['type', 'risk']). Currently, a manual outer loop is required: for v in g._nodes[cols].drop_duplicates()... .

Describe the solution you'd like

g2 = g.collapse('root', match=['type', 'risk'])
g2 = g.collapse('root', match={'type': 'account', 'risk': 'high'})

It should also handle the case of the root id changing..

Describe alternatives you've considered

We can also support a general udf f(n1, n2), but until we get remote mode clearer, e.g., vectorization, wait

Additional context

It may make sense to wait until we've added collapse reductions and optimized those

lmeyerov avatar Apr 23 '22 15:04 lmeyerov