code: def pandas_to_sparse_adjacency(df, src, dst, weight_col):
      """
          Takes a Pandas Dataframe and named src and dst columns into a sparse adjacency matrix in COO format
          Needed for DGL utils
      :param df: edges dataframe
      :param src: source column
      :param dst: destination column
      :param weight_col: optional weight column
      :return: COO sparse matrix, dictionary of src, dst nodes to index
      """
      # use scipy sparse to encode matrix
      from scipy.sparse import coo_matrix
  
      # have to reindex to align edge list with range(n_nodes) with new SRC and DST columns
      df, ordered_nodes_dict = reindex_edgelist(df, src, dst)
  
      eweight = np.array([1] * len(df))
      if weight_col is not None:
          eweight = df[weight_col].values
  
      shape = len(ordered_nodes_dict)
      sp_mat = coo_matrix(
          (eweight, (df[config.SRC], df[config.DST])),
          shape=(shape, shape),
      )
      return sp_mat, ordered_nodes_dict
  
imports: from collections import Counter
  from typing import Dict, Optional, TYPE_CHECKING, Tuple
  import numpy
  import pandas
  from .None import constants
  from .feature_utils import FeatureEngine, FeatureMixin, resolve_feature_engine, XSymbolic, YSymbolic, resolve_X, resolve_y
  from .util import setup_logger
label_desc: Use image node_id 6 for calling a global function with example usage: pandas_to_sparse_adjacency(df, src, dst, weight_col) and returns: sp_mat,  ordered_nodes_dict