pygraphistry icon indicating copy to clipboard operation
pygraphistry copied to clipboard

[FEA] nodes/edges assign

Open lmeyerov opened this issue 3 years ago • 0 comments

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

Typical node/edge equiv code for pandas assign is hard to read and annoying to write, cleaner w/ a native form

Today:

g3 = (g2
  .nodes(lambda g2: g2._nodes.assign(mcapLog10=g2._nodes['marketCap'].apply(np.log10)))
)

Describe the solution you'd like

New nodes_assign(), edges_assign() that generalize pandas assign(), similar to what we did for pipe():

g3 = (g2
  .nodes_assign(
      mcapLog10=g2._nodes['marketCap'].apply(np.log10)
  )
  .nodes_assign(lambda n2: {
     'mcapLog10': n2['marketCap'].apply(np.log10)   # reads _nodes df from current pipeline
  })
)

And same for edges_assign()

lmeyerov avatar Feb 14 '22 09:02 lmeyerov