@@ -726,7 +726,9 @@ def nanmean(
726
726
727
727
728
728
@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 :
730
732
"""
731
733
Parameters
732
734
----------
@@ -738,7 +740,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=
738
740
739
741
Returns
740
742
-------
741
- result : float
743
+ result : float | ndarray
742
744
Unless input is a float array, in which case use the same
743
745
precision as the input array.
744
746
@@ -758,7 +760,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=
758
760
# cases we never need to set NaN to the masked values
759
761
using_nan_sentinel = values .dtype .kind == "f" and mask is None
760
762
761
- def get_median (x , _mask = None ):
763
+ def get_median (x : np . ndarray , _mask = None ):
762
764
if _mask is None :
763
765
_mask = notna (x )
764
766
else :
@@ -794,6 +796,8 @@ def get_median(x, _mask=None):
794
796
795
797
notempty = values .size
796
798
799
+ res : float | np .ndarray
800
+
797
801
# an array from a frame
798
802
if values .ndim > 1 and axis is not None :
799
803
# there's a non-empty array to apply over otherwise numpy raises
0 commit comments