code: def weighted_mean(data):
      
      W, N, mean, d = 0, len(data), 0, 0
      if N < 1:
          return "", ""
      if N == 1:
          return data[0][0], 0
      for x in data:
          W += x[1]  # sum of the weights
      for x in data:
          mean += old_div((float(x[1]) * float(x[0])), float(W))
      for x in data:
          d += (old_div(float(x[1]), float(W))) * (float(x[0]) - mean)**2
      stdev = np.sqrt(d * (old_div(1., (float(N - 1)))))
      return mean, stdev
docs: calculates weighted mean of data