How to subset sparse matrix by value of a label list?
I tried: 
for i in set(news_labels):
     indices = [element for element, x in enumerate(news_labels) if x == i]
     subset = news_data[indices]
and it worked!
I am using fetch_20newsgroups_vectorized data:
import numpy as np
from scipy.sparse import csr_matrix
from sklearn.datasets import fetch_20newsgroups
from sklearn.datasets import fetch_20newsgroups_vectorized
newsgroups = fetch_20newsgroups(subset='all')
labels = newsgroups.target_names
news_data, news_labels = fetch_20newsgroups_vectorized(subset='all', normalize=False, return_X_y=True)
news_labels = [labels[i] for i in news_labels] ### converting integer list to str list
when I try to subset matrix news_data based on groups of news_label (exstract all rows that have label i into a new matrix), it returns the same subset for each label level (there are 20 different levels and news_data is csr_matrix):
for i in set(news_labels):
    print(i)
    subset = news_data[news_labels == i]
How can I subset news_data for every level of news_label?