Concatenate range arrays given start, stop numbers in a vectorized way - NumPy
问题 I have two matrices of interest, the first is a "bag of words" matrix, with two columns: the document ID and the term ID. For example: bow[0:10] Out[1]: array([[ 0, 10], [ 0, 12], [ 0, 19], [ 0, 20], [ 1, 9], [ 1, 24], [ 2, 33], [ 2, 34], [ 2, 35], [ 3, 2]]) In addition, I have an "index" matrix, where every row in the matrix contains the index of the first and last row for a given document ID in the bag of words matrix. Ex: row 0 is the first and last index for doc id 0. For example: index[0