<jupyter_start><jupyter_text>descriptive statistics<jupyter_code>import numpy as np
print(f'NumPy version = {np.__version__}')<jupyter_output>NumPy version = 1.14.5<jupyter_text>1-dim array<jupyter_code>w = np.array([70, 48, 52, 60, 52])
w
w.size # count
np.min(w)
np.max(w)
np.ptp(w) # max - min
np.sum(w)
np.mean(w)
np.median(w)<jupyter_output><empty_output><jupyter_text>use scipy.stats to calc mode<jupyter_code>from scipy import stats
m=stats.mode(w)
m
m[0]
m[0][0]
m[1]
m[1][0]
np.var(w)
np.std(w)<jupyter_output><empty_output><jupyter_text>sort<jupyter_code>w1=np.sort(w) # ascending order
w1
w2=np.sort(w)[::-1] # descending order
w2
w
w.sort() # inplace
w<jupyter_output><empty_output><jupyter_text>2 dim<jupyter_code>b=np.reshape(np.arange(1, 21), (4, 5))
b
np.mean(b)
np.mean(b[0])
np.mean(b[:, 0])
np.mean(b, axis=1)
np.mean(b, axis=0)
np.min(b)
np.min(b, axis=0)
np.min(b, axis=1) # min in each row<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18809776833156217, 'fraction_numerical': 0.040382571732199786, 'mean_word_length': 7.120689655172414, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '390234', 'license': 'MIT', 'n_tokens_mistral': 485, 'n_tokens_neox': 464, 'n_words': 75, 'path': 'numpy_math_op.ipynb', 'repo_name': 'R1SE23/learn_numpy', 'size': '941'}