code: def convert_to_pysal(data):
      
      w = pysal.lat2W(len(data[0]), len(data))
      data = np.array(data)
      data = np.reshape(data, (len(data)*len(data[0]), 1))
      return w, data
docs: Pysal expects a distance matrix, and data formatted in a numpy array.
      This functions takes a data grid and returns those things.