Skip to content

Instantly share code, notes, and snippets.

@kperry2215
Created November 21, 2019 05:19
Show Gist options
  • Save kperry2215/f66ca97dab1cc9481b07a10fb59f07ae to your computer and use it in GitHub Desktop.
Save kperry2215/f66ca97dab1cc9481b07a10fb59f07ae to your computer and use it in GitHub Desktop.
def mann_whitney_u_test(distribution_1, distribution_2):
"""
Perform the Mann-Whitney U Test, comparing two different distributions.
Args:
distribution_1: List.
distribution_2: List.
Outputs:
u_statistic: Float. U statisitic for the test.
p_value: Float.
"""
u_statistic, p_value = stats.mannwhitneyu(distribution_1, distribution_2)
return u_statistic, p_value
#### MAIN FUNCTION ####
#Perform the Mann-Whitney U Test on the two distributions
mann_whitney_u_test(list(df_less_than_50k['age']), list(df_greater_than_50k['age']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment