code: def to_pandas_edges_arrows(G, pos, arrow_length, **kwargs):
      """Convert Graph edges to pandas DataFrame that's readable to Altair."""
      # Get all attributes in nodes
      attributes = ["source", "target", "x", "y", "edge", "pair"]
      for e in G.edges():
          attributes += list(G.edges[e].keys())
      attributes = list(set(attributes))
  
      # Build a dataframe for all edges and their attributes
      df = pd.DataFrame(index=range(G.size() * 2), columns=attributes)
  
      # Add node data to dataframe.
      for i, e in enumerate(G.edges):
          idx = i * 2
          Dy = pos[e[1]][1] - pos[e[0]][1]
          Dx = pos[e[1]][0] - pos[e[0]][0]
  
          data1 = dict(
              edge=i,
              source=e[0],
              target=e[1],
              pair=e,
              x=pos[e[1]][0],
              y=pos[e[1]][1],
              **G.edges[e],
          )
  
          data2 = dict(
              edge=i,
              source=e[0],
              target=e[1],
              pair=e,
              x=pos[e[1]][0] - arrow_length * Dx,
              y=pos[e[1]][1] - arrow_length * Dy,
              **G.edges[e],
          )
  
          df.loc[idx] = data1
          df.loc[idx + 1] = data2
  
      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 3 for calling a global function with example usage: to_pandas_edges_arrows(G, pos, arrow_length) and returns: df