@@ -681,26 +681,26 @@ def get_median(x):
681681 # there's a non-empty array to apply over otherwise numpy raises
682682 if notempty :
683683 if not skipna :
684- return _wrap_results (
685- np .apply_along_axis (get_median , axis , values ), dtype
686- )
684+ res = np .apply_along_axis (get_median , axis , values )
685+
686+ else :
687+ # fastpath for the skipna case
688+ with warnings .catch_warnings ():
689+ # Suppress RuntimeWarning about All-NaN slice
690+ warnings .filterwarnings ("ignore" , "All-NaN slice encountered" )
691+ res = np .nanmedian (values , axis )
687692
688- # fastpath for the skipna case
689- with warnings .catch_warnings ():
690- # Suppress RuntimeWarning about All-NaN slice
691- warnings .filterwarnings ("ignore" , "All-NaN slice encountered" )
692- res = np .nanmedian (values , axis )
693- return _wrap_results (res , dtype )
694-
695- # must return the correct shape, but median is not defined for the
696- # empty set so return nans of shape "everything but the passed axis"
697- # since "axis" is where the reduction would occur if we had a nonempty
698- # array
699- ret = get_empty_reduction_result (values .shape , axis , np .float_ , np .nan )
700- return _wrap_results (ret , dtype )
701-
702- # otherwise return a scalar value
703- return _wrap_results (get_median (values ) if notempty else np .nan , dtype )
693+ else :
694+ # must return the correct shape, but median is not defined for the
695+ # empty set so return nans of shape "everything but the passed axis"
696+ # since "axis" is where the reduction would occur if we had a nonempty
697+ # array
698+ res = get_empty_reduction_result (values .shape , axis , np .float_ , np .nan )
699+
700+ else :
701+ # otherwise return a scalar value
702+ res = get_median (values ) if notempty else np .nan
703+ return _wrap_results (res , dtype )
704704
705705
706706def get_empty_reduction_result (
0 commit comments