Last active
April 4, 2021 22:17
-
-
Save jaymody/cf55a5b94d56fffe24cbcce142c1f7d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import statistics | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
def stats(values, plot=False): | |
# statistics.mode throws an error if there are multiple modes | |
try: | |
mode = statistics.mode(values) | |
except: | |
mode = None | |
d = { | |
"len": len(values), | |
"max": max(values), | |
"min": min(values), | |
"mean": statistics.mean(values), | |
"median": statistics.median(values), | |
"mode": mode, | |
"stdev": statistics.stdev(values), | |
} | |
if plot: | |
sns.distplot(values) | |
plt.show() | |
return d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment