<jupyter_start><jupyter_text><NAME> May 24th, 2021 Codecademy - Analyze Data with Python Path CrunchieMunchies Project Skill Path: Analyze Data with Python  Section: Introduction to Python  Topic: NumPy - A Python Library for Statistics This project builds on the Betty's Bakery project by using more of the statistics features in NumPy      __Description of Task__: "You work in marketing for a food company, which is developing a new kind of tasty, wholesome  cereal called CrunchieMunchies. You need to demonstrate to consumers how healthy your creal is in comparson to other brands.  You've dug up nutritional data on several different competitors. Your task is to use NumPy statistical calculations to  analyze this data and prove that your CrunchieMunchies cereal is the healthiest choice for consumers.<jupyter_code>import numpy as np

calorie_stats = np.genfromtxt("cereal.csv",delimiter=",")
# print(calorie_stats) - used to recreate the data file
# cereal.csv contains calorie counts for other cereal brands

# Context: "There are 60 calories per serving of CrunchieMunchies."
crunch_munch_cals = 60
average_calories = np.mean(calorie_stats)
print("CrunchieMunchies: 60 cals\nCompetition: {0} cals".format(average_calories))
calorie_stats_sorted = np.sort(calorie_stats)
print(calorie_stats_sorted)

median_calories = np.median(calorie_stats)
print("Median: {0}".format(median_calories))
first_quarter = np.percentile(calorie_stats,25)
second_quarter = np.percentile(calorie_stats,75)

#Finding the lowest percentile that is greater than 60 calories
nth_percentile = 50
percentile_value = np.percentile(calorie_stats,nth_percentile)
while percentile_value > 60:
  nth_percentile -= 1
  percentile_value = np.percentile(calorie_stats,nth_percentile)
print(nth_percentile)

#Instruction was to print a few percentiles as well, so here are a few percentiles
for percentile in [20, 15, 10, 5, 4]:
  print("\n{0}th Percentile: {1}\n".format(percentile,np.percentile(calorie_stats,percentile)))
#Percentage of cereals with higher calorie counts
more_calories = np.mean(calorie_stats > 60)
print("{0}% of cereals have more calories!".format(more_calories * 100))

calorie_std = np.std(calorie_stats)
print("\nStandard Deviation: {0}".format(calorie_std))<jupyter_output>96.1038961038961% of cereals have more calories!

Standard Deviation: 19.35718533390827
{'fraction_non_alphanumeric': 0.07627118644067797, 'fraction_numerical': 0.03093220338983051, 'mean_word_length': 6.309597523219814, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '395346', 'license': 'MIT', 'n_tokens_mistral': 794, 'n_tokens_neox': 712, 'n_words': 245, 'path': 'Numpy-PythonLibraryforStatistics/Codecademy_AnalyzeDatawithPython_CrunchieMunchies.ipynb', 'repo_name': 'pdvnny/Codecademy-AnalyzeDatawithPython', 'size': '2365'}