code: def bin(y, bins):
      
      if np.ndim(y) == 1:
          k = 1
          n = np.shape(y)[0]
      else:
          n, k = np.shape(y)
      b = np.zeros((n, k), dtype='int')
      i = len(bins)
      if type(bins) != list:
          bins = bins.tolist()
      binsc = copy.copy(bins)
      while binsc:
          i -= 1
          c = binsc.pop(-1)
          b[np.nonzero(y <= c)] = i
      return b
docs: bin interval/ratio data
  
      Parameters
      ----------
      y : array
          (n,q), values to bin
      bins : array
             (k,1), upper bounds of each bin (monotonic)
  
      Returns
      -------
      b : array
          (n,q), values of values between 0 and k-1
  
      Examples
      --------
      >>> import numpy as np
      >>> import mapclassify as mc
      >>> np.random.seed(1)
      >>> x = np.random.randint(2, 20, (10, 3))
      >>> bins = [10, 15, 20]
      >>> b = mc.classifiers.bin(x, bins)
      >>> x
      array([[ 7, 13, 14],
             [10, 11, 13],
             [ 7, 17,  2],
             [18,  3, 14],
             [ 9, 15,  8],
             [ 7, 13, 12],
             [16,  6, 11],
             [19,  2, 15],
             [11, 11,  9],
             [ 3,  2, 19]])
      >>> b
      array([[0, 1, 1],
             [0, 1, 1],
             [0, 2, 0],
             [2, 0, 1],
             [0, 1, 0],
             [0, 1, 1],
             [2, 0, 1],
             [2, 0, 1],
             [1, 1, 0],
             [0, 0, 2]])