How to compute the z-score value for all elements of an array using a python library?

+1 vote

Best answer

You can use **zscore****()** function of *stats* module present in *scipy*. Check the following example:

>>> from scipy import stats

>>> import numpy as np

>>> a=np.array([10,11,34,21,45,65,32,12])

>>> stats.zscore(a)

array([-1.03539421, -0.98017318, 0.28991038, -0.42796294, 0.89734165,

2.00176214, 0.17946833, -0.92495216])