@@ -726,7 +726,9 @@ def nanmean(
726726
727727
728728@bottleneck_switch ()
729- def nanmedian (values , * , axis : AxisInt | None = None , skipna : bool = True , mask = None ):
729+ def nanmedian (
730+ values : np .ndarray , * , axis : AxisInt | None = None , skipna : bool = True , mask = None
731+ ) -> float | np .ndarray :
730732 """
731733 Parameters
732734 ----------
@@ -738,7 +740,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=
738740
739741 Returns
740742 -------
741- result : float
743+ result : float | ndarray
742744 Unless input is a float array, in which case use the same
743745 precision as the input array.
744746
@@ -758,7 +760,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=
758760 # cases we never need to set NaN to the masked values
759761 using_nan_sentinel = values .dtype .kind == "f" and mask is None
760762
761- def get_median (x , _mask = None ):
763+ def get_median (x : np . ndarray , _mask = None ):
762764 if _mask is None :
763765 _mask = notna (x )
764766 else :
@@ -794,6 +796,8 @@ def get_median(x, _mask=None):
794796
795797 notempty = values .size
796798
799+ res : float | np .ndarray
800+
797801 # an array from a frame
798802 if values .ndim > 1 and axis is not None :
799803 # there's a non-empty array to apply over otherwise numpy raises
0 commit comments