code: def lmannwhitneyu(x,y):
      
      n1 = len(x)
      n2 = len(y)
      ranked = rankdata(x+y)
      rankx = ranked[0:n1]       # get the x-ranks
      ranky = ranked[n1:]        # the rest are y-ranks
      u1 = n1*n2 + (n1*(n1+1))/2.0 - sum(rankx)  # calc U for x
      u2 = n1*n2 - u1                            # remainder is U for y
      bigu = max(u1,u2)
      smallu = min(u1,u2)
      T = math.sqrt(tiecorrect(ranked))  # correction factor for tied scores
      if T == 0:
          raise ValueError('All numbers are identical in lmannwhitneyu')
      sd = math.sqrt(T*n1*n2*(n1+n2+1)/12.0)
      z = abs((bigu-n1*n2/2.0) / sd)  # normal approximation for prob calc
      return smallu, 1.0 - zprob(z)
docs: Calculates a Mann-Whitney U statistic on the provided scores and
  returns the result.  Use only when the n in each condition is < 20 and
  you have 2 independent samples of ranks.  NOTE: Mann-Whitney U is
  significant if the u-obtained is LESS THAN or equal to the critical
  value of U found in the tables.  Equivalent to Kruskal-Wallis H with
  just 2 groups.
  
  Usage:   lmannwhitneyu(data)
  Returns: u-statistic, one-tailed p-value (i.e., p(z(U)))