it = np.nditer([data, None], flags=['reduce_ok', 'external_loop'], op_flags
    =[['readonly'], ['readwrite', 'allocate']], order='F', op_axes=[None,
    red_axes])
How to do a reduction with numpy.nditer in the first axis