title: Grouping of a list of lists values into equal distance bins
body: <p>Following <a href="https://stackoverflow.com/questions/65498237/grouping-of-a-lists-values-into-equal-distance-bins">this SO</a> I managed to group 1 list values into equal distance bins:</p>
  <pre><code>y = list(range(100))
  def list_grouper(long_list, bins_number):
      bins = np.linspace(min(long_list), max(long_list), bins_number)
      bins_idx = np.digitize(long_list, bins)
      bins_idx = bins_idx -1 
      
      return bins_idx    
      
  list_grouper(y, 20)
  
  &gt;&gt;&gt;array([ 0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  3,
          3,  3,  3,  3,  4,  4,  4,  4,  4,  4,  5,  5,  5,  5,  5,  6,  6,
          6,  6,  6,  7,  7,  7,  7,  7,  8,  8,  8,  8,  8,  9,  9,  9,  9,
          9,  9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12,
         13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16,
         16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 19])
  </code></pre>
  <p>Is there a way to do the same thing but over a list of lists?</p>
  <pre><code>list_of_lists = [list(range(20)), list(range(10, 40)), list(range(40, 60))]
  </code></pre>
  <p>Such that all of the values (from all the lists) will be considered when dividing into equal distances (rather than each list's values separately), but each list will still be separate?<br />
  e.g.</p>
  <pre><code>list_of_lists_output = [[0,0,0,0,1,1,1...], [5,5...], [8...]]
  </code></pre>
  <p><strong>Update</strong>:<br />
  @Giacomo method almost works. It works if the lists have the same number of values. Otherwise I'm getting these 2 errors:</p>
  <pre><code>list_of_lists = [list(range(20)), list(range(10, 40)), list(range(40, 60))]
  list_of_lists = np.array(list_of_lists)
  list_grouper2(list_of_lists, 5)
  
  &gt;&gt;&gt;ValueError: object too deep for desired array
  </code></pre>
  <p>Or this:</p>
  <pre><code>list_of_lists = [list(range(20)), list(range(10, 40))]
  list_of_lists = np.array(list_of_lists)
  list_grouper2(list_of_lists, 5)
  &gt;&gt;&gt;ValueError: operands could not be broadcast together with shapes (30,) (20,) 
  </code></pre>