<jupyter_start><jupyter_text>**NumPy Arrays**<jupyter_code>import numpy as np
my_list=[1,2,3]
arr=np.array(my_list)
#converts the list into array
arr
#show the array
matrix_list=[[1,2,3],[4,5,6],[7,8,9]]
my_matrix=np.array(matrix_list)
#nested lists make a matrix
my_matrix
#show the matrix
np.arange(0,11)
#the arange() function is just like the range() function
#(start,stop,step) start inclusive, but stop exclusive
np.arange(0,11,2)
np.zeros(4)
#makes an array of n zeros (1D unless passed a tuple)
np.zeros((4,4))
#when passed a tuple, it creates a 2D array (matrix)
np.zeros((2,3))
np.ones(13)
np.ones((2,4))
#linspace generates evenly spaced numbers over a specified interval
np.linspace(0,5,10)
np.linspace(0,5,10)*12
np.eye(4)
np.eye(7)
np.random.rand(3)
#generates n random numbers all in between 0 and 1 (but not including 1).
#normalized - between 0 and 1
np.random.rand(3,3)
#generates a matrix of random numbers between 0 and 1
np.random.randn(4)
#generates random integers, not normalized
np.random.randn(3,3)
np.random.randint(1,100)
#generates one random integer in the given interval
np.random.randint(1,100,4)
arr=np.arange(25)
arr
ranarr=np.random.randint(0,50,10)
ranarr
arr.reshape(5,5)
ranarr.max()
ranarr.min()
ranarr.argmax()
ranarr.argmin()
arr.shape
arr
arr=arr.reshape(5,5)
arr.shape
arr.dtype<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14137675795706883, 'fraction_numerical': 0.05551443375277572, 'mean_word_length': 6.308108108108108, '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': '477510', 'license': 'MIT', 'n_tokens_mistral': 567, 'n_tokens_neox': 540, 'n_words': 145, 'path': 'NumPy Arrays.ipynb', 'repo_name': 'dimensionsix/NumPy', 'size': '1351'}