def resample(x, t, start, end, step): bins = np.arange(start, end+step, step) inds = np.digitize(t,bins) y = np.empty(len(bins)) * np.nan y[inds] = x return y, bins x = [3,6,9,12,15,18,21,24] t = [0,4,8,10,45,67,78,90] x_re, t_re = resample(x, t, 0, 100, 5)