'Compute percentiles for sparse matrices.
Parameters
X : sparse matrix CSC, shape (n_samples, n_features)
The data used to scale along the features axis. The sparse matrix
needs to be nonnegative.'

def _sparse_fit(self, X, random_state):

    (n_samples, n_features) = X.shape
    references = list(map((lambda x: (x * 100)), self.references_))
    self.quantiles_ = []
    for feature_idx in range(n_features):
        column_nnz_data = X.data[X.indptr[feature_idx]:X.indptr[(feature_idx + 1)]]
        if (len(column_nnz_data) > self.subsample):
            column_subsample = ((self.subsample * len(column_nnz_data)) // n_samples)
            if self.ignore_implicit_zeros:
                column_data = np.zeros(shape=column_subsample, dtype=X.dtype)
            else:
                column_data = np.zeros(shape=self.subsample, dtype=X.dtype)
            column_data[:column_subsample] = random_state.choice(column_nnz_data, size=column_subsample, replace=False)
        else:
            if self.ignore_implicit_zeros:
                column_data = np.zeros(shape=len(column_nnz_data), dtype=X.dtype)
            else:
                column_data = np.zeros(shape=n_samples, dtype=X.dtype)
            column_data[:len(column_nnz_data)] = column_nnz_data
        if (not column_data.size):
            self.quantiles_.append(([0] * len(references)))
        else:
            self.quantiles_.append(np.percentile(column_data, references))
    self.quantiles_ = np.transpose(self.quantiles_)
