code: def from_dataframe(df,
                     source_col='source',
                     target_col='target',
                     interaction_col='interaction',
                     name='From DataFrame',
                     edge_attr_cols=[]):
      
  
      network = cyjs.get_empty_network(name=name)
      nodes = set()
      if edge_attr_cols is None:
          edge_attr_cols = []
  
      for index, row in df.iterrows():
          s = row[source_col]
          t = row[target_col]
          if s not in nodes:
              nodes.add(s)
              source = get_node(s)
              network['elements']['nodes'].append(source)
          if t not in nodes:
              nodes.add(t)
              target = get_node(t)
              network['elements']['nodes'].append(target)
  
          extra_values = {column: row[column]
                          for column in edge_attr_cols
                          if column in df.columns}
  
          network['elements']['edges'].append(
              get_edge(s, t, interaction=row[interaction_col], **extra_values)
          )
      return network
docs: Utility to convert Pandas DataFrame object into Cytoscape.js JSON
  
      :param df: Dataframe to convert.
      :param source_col: Name of source column.
      :param target_col: Name of target column.
      :param interaction_col: Name of interaction column.
      :param name: Name of network.
      :param edge_attr_cols: List containing other columns to consider in df as
          edges' attributes.
      :return: Dictionary version of df.