An effective way is to actually compact the entire matrix, and then standardize it in the usual way with
X = X.toarray() X -= X.mean() X /= X.std()
As @Sebastian noted in his comments, standardization destroys the sparseness structure (introduces many nonzero elements) at the subtraction stage, so there is no need to keep the matrix in a sparse format.
Fred foo
source share