DATA SCIENCE LAB-LAB 2 EXP:
import numpy as np
arr = [Link]([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
newarr = [Link](4, 3)
print(newarr)
2A:
import numpy as np
n = [Link]([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]])
print(type(n))
print([Link])
print("Dimensions = ",[Link])
2B:
import numpy as np
arr = [Link]([1, 2, 3, 4], ndmin=5)
print(arr)
print('shape of array :', [Link])
2C:
# Python program explaining
# [Link]() method
# importing numpy
import numpy as np
# Making a random array
arr = [Link]([[1, 2, 3, 4], [5, 6, 7, 8]])
# By default, give the total number of elements.
print([Link](arr))
2D:
# importing numpy
import numpy as np
# creating a numpy array
array = [Link]([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
# printing array
print("Array : " + str(array))
# length of array
n = [Link]
# N-D array N dimension
N=4
# calculating M
M = n//N
# reshaping numpy array
# converting it to 2-D from 1-D array
reshaped1 = [Link]((N, M))
# printing reshaped array
print("First Reshaped Array : ")
print(reshaped1)
# creating another reshaped array
reshaped2 = [Link](array, (2, 8))
# printing reshaped array
print("Second Reshaped Array : ")
print(reshaped2)
2E:
import numpy as np
# Create two 2D arrays
array1 = [Link]([[1, 2, 3], [4, 5, 6]])
array2 = [Link]([[7, 8, 9], [10, 11, 12]])
# Flatten the arrays and concatenate them
concatenated_array = [Link](([Link](), [Link]()))
print("Array 1:")
print(array1)
print("\nArray 2:")
print(array2)
print("\nConcatenated Array:")
print(concatenated_array)
2F:
# importing python module named numpy
import numpy as np
# making a 3x3 array
gfg = [Link]([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
# before transpose
print(gfg, end ='\n\n')
# after transpose
print([Link]())