code: def to_pandas_nodes(G, pos):
      """Convert Graph nodes to pandas DataFrame that's readable to Altair."""
      # Get all attributes in nodes
      attributes = ["x", "y"]
      for n in G.nodes():
          attributes += list(G.nodes[n].keys())
      attributes = list(set(attributes))
  
      # Build a dataframe for all nodes and their attributes
      df = pd.DataFrame(index=G.nodes(), columns=attributes)
  
      # Add node data to dataframe.
      for n in G.nodes:
          data = dict(x=pos[n][0], y=pos[n][1], **G.nodes[n])
          df.loc[n] = data
  
      return df
  
file_path: nx_altair/nx_altair/core.py
imports: import pandas
  import networkx
  import altair
  from ._utils import despine
label_desc: Use image node_id 1 for calling a global function with example usage: to_pandas_nodes(G, pos) and returns: df