code: def numpy_buffer(ndarray):
      
      # Credits to: https://github.com/joblib/joblib/blob/04b001861e1dd03a857b7b419c336de64e05714c/joblib/hashing.py
  
      if isinstance(ndarray, (pd.Series, pd.DataFrame)):
          ndarray = ndarray.values
  
      if ndarray.flags.c_contiguous:
          obj_c_contiguous = ndarray
      elif ndarray.flags.f_contiguous:
          obj_c_contiguous = ndarray.T
      else:
          obj_c_contiguous = ndarray.flatten()
  
      obj_c_contiguous = obj_c_contiguous.view(np.uint8)
  
      if hasattr(np, 'getbuffer'):
          return np.getbuffer(obj_c_contiguous)
      else:
          return memoryview(obj_c_contiguous)
docs: Creates a buffer from c_contiguous numpy ndarray.