code: def df_to_array(df, netshape, nettype):
      
      if len(df) > 0:
          idx = np.array(list(map(list, df.values)))
          G = np.zeros([netshape[0], netshape[0], netshape[1]])
          if idx.shape[1] == 3:
              if nettype[-1] == 'u':
                  idx = np.vstack([idx, idx[:, [1, 0, 2]]])
              idx = idx.astype(int)
              G[idx[:, 0], idx[:, 1], idx[:, 2]] = 1
          elif idx.shape[1] == 4:
              if nettype[-1] == 'u':
                  idx = np.vstack([idx, idx[:, [1, 0, 2, 3]]])
              weights = idx[:, 3]
              idx = np.array(idx[:, :3], dtype=int)
              G[idx[:, 0], idx[:, 1], idx[:, 2]] = weights
      else:
          G = np.zeros([netshape[0], netshape[0], netshape[1]])
      return G
docs: Returns a numpy array (snapshot representation) from thedataframe contact list
  
      Parameters:
          df : pandas df
              pandas df with columns, i,j,t.
          netshape : tuple
              network shape, format: (node, time)
          nettype : str
              'wu', 'wd', 'bu', 'bd'
  
      Returns:
      --------
          G : array
              (node,node,time) array for the network