def nanpercentile(values, q, axis, na_value, mask, ndim, interpolation):
if not lib.is_scalar(mask) and mask.any():<EOL><INDENT>if ndim == <NUM_LIT:1>:<EOL><INDENT>return _nanpercentile_1d(values, mask, q, na_value,<EOL>interpolation=interpolation)<EOL><DEDENT>else:<EOL><INDENT>if mask.ndim < values.ndim:<EOL><INDENT>mask = mask.reshape(values.shape)<EOL><DEDENT>if axis == <NUM_LIT:0>:<EOL><INDENT>values = values.T<EOL>mask = mask.T<EOL><DEDENT>result = [_nanpercentile_1d(val, m, q, na_value,<EOL>interpolation=interpolation)<EOL>for (val, m) in zip(list(values), list(mask))]<EOL>result = np.array(result, dtype=values.dtype, copy=False).T<EOL>return result<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return np.percentile(values, q, axis=axis, interpolation=interpolation)<EOL><DEDENT>
Wraper for np.percentile that skips missing values.

Parameters
----------
values : array over which to find quantiles
q : scalar or array of quantile indices to find
axis : {0, 1}
na_value : scalar
    value to return for empty or all-null values
mask : ndarray[bool]
    locations in values that should be considered missing
ndim : {1, 2}
interpolation : str

Returns
-------
quantiles : scalar or array