How to display median when mann-whitney u test is applied in python?

I am using scipy.stats.mannwhitneyu to apply mann-whitney test to check my hypothesis on two categories. However, I am interested in finding the median values which are computed to apply mann-whitney. Is there any way I can print those values in the aforementioned library?

Thanking in anticipation.

• How are your values for the array-like stored? lists? – chemicalwill May 3 at 19:57
• How about printing medians directly from data. Are you sure samples are of comparable shape so you can view M-W as a test of diff btw 2 medians? [In R, anyhow, medians are not part of the output for two-sample 'wilcox.test'.] – BruceET May 3 at 21:26

Mann-Whitney $$U$$ 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.
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.