@disallow('<STR_LIT>')<EOL>@bottleneck_switch()<EOL>def nanmedian(values, axis=None, skipna=True, mask=None):
def get_median(x):<EOL><INDENT>mask = notna(x)<EOL>if not skipna and not mask.all():<EOL><INDENT>return np.nan<EOL><DEDENT>return np.nanmedian(x[mask])<EOL><DEDENT>values, mask, dtype, dtype_max, _ = _get_values(values, skipna, mask=mask)<EOL>if not is_float_dtype(values):<EOL><INDENT>values = values.astype('<STR_LIT>')<EOL>values[mask] = np.nan<EOL><DEDENT>if axis is None:<EOL><INDENT>values = values.ravel()<EOL><DEDENT>notempty = values.size<EOL>if values.ndim > <NUM_LIT:1>:<EOL><INDENT>if notempty:<EOL><INDENT>if not skipna:<EOL><INDENT>return _wrap_results(<EOL>np.apply_along_axis(get_median, axis, values), dtype)<EOL><DEDENT>return _wrap_results(np.nanmedian(values, axis), dtype)<EOL><DEDENT>shp = np.array(values.shape)<EOL>dims = np.arange(values.ndim)<EOL>ret = np.empty(shp[dims != axis])<EOL>ret.fill(np.nan)<EOL>return _wrap_results(ret, dtype)<EOL><DEDENT>return _wrap_results(get_median(values) if notempty else np.nan, dtype)<EOL>
Parameters
----------
values : ndarray
axis: int, optional
skipna : bool, default True
mask : ndarray[bool], optional
    nan-mask if known

Returns
-------
result : float
    Unless input is a float array, in which case use the same
    precision as the input array.

Examples
--------
>>> import pandas.core.nanops as nanops
>>> s = pd.Series([1, np.nan, 2, 2])
>>> nanops.nanmedian(s)
2.0