<jupyter_start><jupyter_text>Daan - stats section - excercises<jupyter_code># imports
import pandas as pd
import numpy as np
import math
import statistics as stats
import matplotlib.pyplot as plt
% matplotlib inline
# input: paste list inside of '[]'
my_list = [15, 4, 3, 8, 15, 22, 7, 9, 2, 3, 3, 12, 6]
#my_list = [45, 68, 92, 53, 105, 56, 24, 15, 155]
# turn list into dataframe for plotting
df = pd.DataFrame(np.array(my_list).reshape(-1,1),columns=['Numbers'])
df['Numbers'].hist();
# sorted list
sorted_list = sorted(my_list)
# 5 number summary
n_list = len(sorted_list)
min_list = min(sorted_list)
max_list = max(sorted_list)
# mean = average
mean_list = np.mean(sorted_list)
range_list = max(sorted_list) - min(sorted_list)
# median = middle
median_list = stats.median(sorted_list)
# mode = most
mode_list = stats.mode(sorted_list)
# numpy array
arr = np.array(sorted_list)
# percentiles
first_percentile = np.percentile(arr, 25)
first_percentile_floor = math.floor(first_percentile)
second_percentile = np.percentile(arr, 50)
stats.median(my_list)
third_percentile = np.percentile(arr, 75)
IQR_list = third_percentile - first_percentile
# variance and std
variance_arr = np.var(arr)
standard_deviation_arr = np.std(arr)
# outputs
'n = ' + str(n_list)
'median = ' + str(median_list)
'mode = ' + str(mode_list)
'min_list = ' + str(min_list)
'max_list = ' + str(max_list)
'mean_list = ' + str(mean_list)
'range_list = ' + str(range_list)
'1stQuart_list = ' + str(first_percentile)
'2ndQuart_list = ' + str(second_percentile)
'3rdQuart_list = ' + str(third_percentile)
'IQR_list = ' + str(IQR_list)
'var_list = ' + str(variance_arr)
'std_list = ' + str(standard_deviation_arr)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13500876680303917, 'fraction_numerical': 0.02863822326125073, 'mean_word_length': 6.016393442622951, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '480897', 'license': 'MIT', 'n_tokens_mistral': 716, 'n_tokens_neox': 659, 'n_words': 145, 'path': 'stats_lessons/Stats_intro_and_testing.ipynb', 'repo_name': 'Zabamund/datasci-nano', 'size': '1711'}