<jupyter_start><jupyter_text>Basic Numpy Operations<jupyter_code>import numpy as np
a=[1,2,11,6,8,18,2]

na=np.array(a)

print(type(na))
print(na.shape) #its a rank 1 numpy array with 7 items
#lets print out an elemant at index 2
print(na[2])
#isolate an entire chunk based on start index-end index
#print out values at start to end-1 index location

print(na[1:5])
#use a step of two

print(na[1:5:2])
#negative index
#print out values at start to end+1 index location

print(a[-7:-3]) #will isolate numbers till -4
#print last item
print(a[-1])
#items start at one index and all the way to the end

print(a[3:])
#print items from begining through end-1

print(a[:4])
b=a[:] #copy an array
print(b)
#concatenate two numpy arrays

x=np.array([2,6,8,4])

y=np.array([11,8,2])

z=np.concatenate([x,y])

print(z)<jupyter_output>[ 2  6  8  4 11  8  2]<jupyter_text>Multi-dimensional array operations<jupyter_code>arr=[[1,2,3,4],[3,4,5,6],[7,8,9,6],[12,7,10,9],[2,11,8,10]]

narr=np.array(arr) #convert array into numpy array

print (narr)
print(narr[0]) #print first row at row index 0
print(narr[2]) #print 3rd row, at row index 2
print(narr[2,3]) #print contents of row with index 0 and column with index 1 [row,columm]
narr[3,0]=14 #replace value at a location

print(narr)
#get the last row
print(narr[-1])
#get the 2nd last
print(narr[-2])
# print rows and columns

print(narr[1:4,2:5]) #rows: 1 to 4-1 and columns 2 to 5-1
###concatenation row and column wise

a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6]])

#concatenate row wise 

c=np.concatenate((a, b))

print(c)<jupyter_output>[[1 2]
 [3 4]
 [5 6]]
{'fraction_non_alphanumeric': 0.15933044017358958, 'fraction_numerical': 0.06509609423434594, 'mean_word_length': 5.207692307692308, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '444308', 'license': 'MIT', 'n_tokens_mistral': 703, 'n_tokens_neox': 665, 'n_words': 209, 'path': 'section2/lecture14_op.ipynb', 'repo_name': 'PacktPublishing/PyTorch-Bootcamp-for-Artificial-Neural-Networks-and-Deep-Learning-Applications', 'size': '1613'}