return values_sorted[median_index]
print(weighted_median([1, 3, 0, 7], [2, 3, 3, 9]))
print(np.median([1, 1, 0, 0, 0, 3, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7]))
Python: weighted median algorithm with pandas