Convenience library to perform row/column operations over numpy and scipy matrices. Provides an interface similar to base R matrix methods/MatrixStats methods in python.
Install from pypi
pip install mopsyfrommopsyimportcolsumimportrandomfromrd# generate a random sparse array with some densityfromscipy.sparseimportrandommat=random(10, 150, 0.25)
# generate random groupsngrps=15gsets= [xforxinrange(15)]
groups= [rd.choice(gsets) forxinrange(mat.shape[axis])]
colsum(mat, groups)Methods are available to perform sum, median, mean along any axis. a generic apply method is also available for perform row-wise or column-wise operations.
This project has been set up using PyScaffold 4.1.1. For details and usage information on PyScaffold see https://pyscaffold.org/.