Mann-Whitney test is not a test of median, but rather a more general test on whether the two sample distributions are different - see this BMJ article for a discussion.

Thus, it is unlikely for an implementation of the Mann-Whitney test to compute the median of the two samples and run any direct comparisons between them, as there is no need to do that to calculate the test statistic. The implementation in SciPy is no exception.

Having that said, given you are using scipy.stats.mannwhitneyu, which requires two array-like arguments that represent the two samples. You can simply calculate the medians by running each argument through any library that calculate the median of an array, e.g. numpy.median.

Answer from B.Liu on Stack Exchange
🌐
SciPy
docs.scipy.org › doc › scipy › reference › generated › scipy.stats.median_test.html
median_test — SciPy v1.17.0 Manual
The “grand median” of all the data is computed, and a contingency table is formed by classifying the values in each sample as being above or below the grand median. The contingency table, along with correction and lambda_, are passed to scipy.stats.chi2_contingency to compute the test statistic and p-value.
🌐
Stack Overflow
stackoverflow.com › questions › 65740561 › median-test-in-python-for-arrays-with-different-length
median test in python for arrays with different length - Stack Overflow
from scipy.stats import median_test stat, p, med, tbl = median_test(a[0], a[1], a[2],a[3]) results: stat 3.228017883755589 p 0.35778751941884523 med 0.00873917447505705 tbl [[28 21 7 2] [33 21 4 0]]
🌐
GitHub
gist.github.com › wanderview › 8285920
Python Median Test - Gist - GitHub
Python Median Test. GitHub Gist: instantly share code, notes, and snippets.
🌐
Deepnote
deepnote.com › app › morris › Bootstrapping-Medians-in-Python-97132454-9e6a-43a7-a7de-235e4e42dcf3
Bootstrapping Medians in Python
November 10, 2023 - ios_sample = [] for i in range(samples): ios_sample += [ios.sample(draws, replace=True).median()] ios_sample = pd.DataFrame(ios_sample) android_sample = [] for i in range(samples): android_sample += [android.sample(draws, replace=True).median()] android_sample = pd.DataFrame(android_sample) the distributions are normalish looking (play around with the number of samples and/or number of draws to see how the histograms change ... fig,axs = plt.subplots(1,2) axs[0].hist(android_sample, bins=range(5,15)) axs[0].set_title('android') axs[1].hist(ios_sample, bins=range(5,15)) axs[1].set_title('ios') plt.show() from here we can just run a regular t test on the average median from the sampled data
🌐
6 Sigma
6sigma.us › articles › mood’s median non-parametric hypothesis test. a complete guide
Mood's Median Non-Parametric Hypothesis Test. A Complete Guide - SixSigma.us
March 6, 2025 - This will output the test statistic, p-value, and other relevant metrics for Mood’s median test on the two sample vectors x1 and x2. For Python, the scipy.stats module provides the median_test() function to conduct the test.
🌐
DataCamp
campus.datacamp.com › courses › foundations-of-inference-in-python › hypothesis-testing-toolkit
Comparing medians | Python
Each of the university ranking organizations you just looked at also included a "total score" for each university. You'll start by determining if the scores are approximately normal by using a histogram. If they are not, you will perform a Mood's median test to compare their medians.
🌐
SciPy
docs.scipy.org › doc › scipy-0.19.1 › reference › generated › scipy.stats.median_test.html
scipy.stats.median_test — SciPy v0.19.1 Reference Guide
The “grand median” of all the data is computed, and a contingency table is formed by classifying the values in each sample as being above or below the grand median. The contingency table, along with correction and lambda_, are passed to scipy.stats.chi2_contingency to compute the test statistic ...
🌐
GeeksforGeeks
geeksforgeeks.org › find-median-of-list-in-python
Find Median of List in Python - GeeksforGeeks
April 12, 2023 - # Python3 code to demonstrate working of # Median of list # Using loop + "~" operator # initializing list test_list = [4, 5, 8, 9, 10, 17] # printing list print("The original list : " + str(test_list)) # Median of list # Using loop + "~" operator test_list.sort() mid = len(test_list) // 2 res = (test_list[mid] + test_list[~mid]) / 2 # Printing result print("Median of list is : " + str(res))
Find elsewhere
🌐
Boardflare
boardflare.com › python-functions › statistical › independent-tests › median_test
MEDIAN_TEST | Boardflare
from scipy.stats import median_test as scipy_median_test from typing import List, Optional, Union def median_test(samples: List[List[float]], ties: str = "below") -> Union[List[List[Optional[float]]], str]: """ Performs Mood’s median test to determine if two or more independent samples come from populations with the same median.
🌐
Rcompanion
rcompanion.org › python › F09.html
Mood's Median Test - Python Handbook
As mentioned in the SAEPER chapter, we’ll invert the scale on the Likert item responses. This is related to so many responses being equal to the global median, 4.
🌐
SciPy
docs.scipy.org › doc › scipy-0.15.1 › reference › generated › scipy.stats.median_test.html
scipy.stats.median_test — SciPy v0.15.1 Reference Guide
January 18, 2015 - The “grand median” of all the data is computed, and a contingency table is formed by classifying the values in each sample as being above or below the grand median. The contingency table, along with correction and lambda_, are passed to scipy.stats.chi2_contingency to compute the test statistic ...
🌐
Aaronschlegel
aaronschlegel.me › median-test.html
Median Test
August 20, 2020 - Levene's Test for Equality of Variances with Python · Analysis · Calculus · Data Science · Finance · Linear Algebra · Machine Learning · nasapy · petpy · poetpy · Python · R · SQL · Statistics · Median Test · Chi-Square Test of Independence for R x C Contingency Tables ·
🌐
SciPy
docs.scipy.org › doc › scipy-0.16.1 › reference › generated › scipy.stats.median_test.html
scipy.stats.median_test — SciPy v0.16.1 Reference Guide
The “grand median” of all the data is computed, and a contingency table is formed by classifying the values in each sample as being above or below the grand median. The contingency table, along with correction and lambda_, are passed to scipy.stats.chi2_contingency to compute the test statistic ...
🌐
SciPy
docs.scipy.org › doc › scipy-0.18.1 › reference › generated › scipy.stats.median_test.html
scipy.stats.median_test — SciPy v0.18.1 Reference Guide
The “grand median” of all the data is computed, and a contingency table is formed by classifying the values in each sample as being above or below the grand median. The contingency table, along with correction and lambda_, are passed to scipy.stats.chi2_contingency to compute the test statistic ...
🌐
GeeksforGeeks
geeksforgeeks.org › machine learning › moods-median-test
Mood's Median Test - GeeksforGeeks
August 25, 2021 - Python for Machine Learning · ... Suggest changes · 1 Likes · Like · Report · Mood's Median Test: It is a non-parametric alternative to one way ANOVA....
🌐
Rcompanion
rcompanion.org › python › F05.html
Python Handbook: Mood’s Median Test for Two-sample Data
MedianTestResult(statistic=9.8, pvalue=0.0017451186995289028, median=3.5, table=array([[1, 9], [9, 1]], dtype=int64)) The output above reports the test statistic and p-value. The median listed is the overall median of observations pooled across groups.
🌐
SciPy
docs.scipy.org › doc › scipy › reference › generated › scipy.stats.kruskal.html
kruskal — SciPy v1.17.0 Manual
Scientific Python Forum · Search Ctrl+K · scipy.stats. scipy.stats.kruskal(*samples, nan_policy='propagate', axis=0, keepdims=False)[source]# Compute the Kruskal-Wallis H-test for independent samples. The Kruskal-Wallis H-test tests the null hypothesis that the population median of all of ...
🌐
TestMu AI
community.testmuai.com › ask a question
How to find Python median of a list? - Ask a Question - TestMu AI (formerly LambdaTest) Community
November 15, 2024 - The list can have any size, and the numbers are not guaranteed to be in any particular order. If the list contains an even number of elements, the function should return the average of the middle two elements.
🌐
Stack Overflow
stackoverflow.com › questions › 44888205 › different-pv-results-for-median-test-in-r-and-python
Different pv results for median test in R and python - Stack Overflow
July 3, 2017 - It is 1) calculating the global median: med=median(c(z,y)), 2) constructing a contingency table of how many values in z and y fall below vs above med: m=matrix(c(sum(z>med),sum(z<=med),sum(y>med),sum(y<=med)),2,2).