You are on page 1of 1

dtype=we can know what about data we are working

ndim=it will give the number of dimension


shape=it will give the number of rows and columns
size=it will give the size of the entire array

fuction:
.flatten()=it will flat the array from two or more dimension to one dimension
ex:
from numpy import *
arr1=array([
[1,2,4],
[3,2,5]
])
arr2=arr1.flatten()
print(arr2)

otput:
PS C:\Users\hp\work> & "C:/Program Files/Python311/python.exe"
c:/Users/hp/work/search.py
[1 2 4 3 2 5]

.reshape(x,y)=we can convert single dimensional array into three dimensional


array.
x=number of rows
y=number of columns
ex:
from numpy import *
arr1=array([
[1,2,4,5,6,7],
[3,2,5,4,9,8]
])
arr2=arr1.flatten()
arr3=arr2.reshape(3,4)
print(arr3)

output:
PS C:\Users\hp\work> & "C:/Program Files/Python311/python.exe"
c:/Users/hp/work/search.py
[[1 2 4 5]
[6 7 3 2]
[5 4 9 8]]
PS C:\Users\hp\work>

matrix:
from numpy import *
m=matrix("1,2;3,4;3,4;6,7")
print(m)

output:
[[1 2]
[3 4]
[3 4]
[6 7]]
PS C:\Users\hp\work>

You might also like