<jupyter_start><jupyter_text>Broadcasting<jupyter_code>import numpy as np
my_3D_array = np.arange(70)
my_3D_array.shape = (2,7,5)
my_3D_array
# shape
my_3D_array.shape
# number of dimensions
my_3D_array.ndim
# size; number of elements
my_3D_array.size
# data type for each element
my_3D_array.dtype
5 * my_3D_array - 2
left_mat = np.arange(6).reshape((2,3))
right_mat = np.arange(15).reshape((3,5))
np.inner(left_mat, right_mat)
np.dot(left_mat, right_mat)<jupyter_output><empty_output><jupyter_text>Operations along axes<jupyter_code>my_3D_array
# shape
my_3D_array.shape
my_3D_array.sum()
(69 * 70)/2
my_3D_array.sum(axis=0)
my_3D_array.sum(axis=1)
my_3D_array.sum(axis=2)<jupyter_output><empty_output><jupyter_text>Broadcasting Rules<jupyter_code>my_2D_array = np.ones(35, dtype='int_').reshape((7,5)) * 3
my_2D_array
my_random_2D_array = np.random.random((7,5))
np.set_printoptions(precision=4)
my_3D_array * my_random_2D_array
my_vector = np.arange(5) * 7
my_vector[0] = -1
my_vector
my_3D_array / my_vector
my_3D_array % my_vector<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12664165103189493, 'fraction_numerical': 0.051594746716697934, 'mean_word_length': 8.278260869565218, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '510728', 'license': 'MIT', 'n_tokens_mistral': 497, 'n_tokens_neox': 483, 'n_words': 67, 'path': 'numpy-data-science-essential-training/Ex_Files_NumPy_Data_EssT/Exercise Files/Ch 3/03_03/Finish/Broadcasting.ipynb', 'repo_name': 'saint1729/in-learning', 'size': '1066'}