Quantile/percentile insert the dimensions of q at the beginning of the result. Nanquantile seems not to be written to correctly support multi-dimensional q and ends up splitting it up:
a = np.ones((3, 4))
q = np.full((1, 2), 0.5)
print(np.quantile(a, q, axis=1).shape)
# (1, 2, 3) correct
print(np.nanquantile(a, q, axis=1).shape)
# (1, 3, 2) mangled up
The axes contributed by q of shape (1, 2) should end up at the beginning but get split.
(Reported by @aschaffer)