Just use convolve and mean:
out = np.convolve( np.mean(x, axis=1), np.ones(3)/3, mode='valid', )
P.S. Maybe [5998], not [5997]?