code: def zscore(vec):
      r"""Calculate the Z-Score.
  
      Parameters
      ----------
      vec : pandas.Series
          The input array for calculating the Z-Score.
  
      Returns
      -------
      zscore : float
          The value of the Z-Score.
  
      References
      ----------
      To calculate the Z-Score, you can find more information here [ZSCORE]_.
  
      .. [ZSCORE] https://en.wikipedia.org/wiki/Standard_score
  
      Example
      -------
  
      >>> vec.rolling(window=20).apply(zscore)
  
      """
      n1 = np.count_nonzero(vec)
      n2 = len(vec) - n1
      fac1 = float(2 * n1 * n2)
      fac2 = float(n1 + n2)
      rbar = fac1 / fac2 + 1
      sr2num = fac1 * (fac1 - n1 - n2)
      sr2den = math.pow(fac2, 2) * (fac2 - 1)
      sr = math.sqrt(sr2num / sr2den)
      if sr2den and sr:
          zscore = (runs(vec) - rbar) / sr
      else:
          zscore = 0
      return zscore
  
imports: from alphapy.calendrical import biz_day_month
  from alphapy.calendrical import biz_day_week
  from alphapy.globals import NULLTEXT
  from alphapy.globals import BSEP, PSEP, USEP
  from alphapy.variables import vexec
  import itertools
  import logging
  import math
  import numpy
  import pandas
label_desc: Use image node_id 52 for calling a global function with example usage: zscore(vec) and returns: zscore