Attributes of a NumPy Array

Machine Learning courses with 100+ Real-time projects Start Now!!

Program 1

# ndim  , shape  , size , dtype , itemsize , nbyte 
# max() , min(),sum(),mean() ,any(),all(),where()
import numpy as np


# any(),all(),where()

ar1=np.array([48,13,27,330,448,50,77,88,399,12]) # old price
ar2=np.array([45,13,27,330,448,50,77,88,399,12]) # new price

ar3=np.where(ar1%2==0,ar1,0)
print("ar1=",ar1)
print("ar3=",ar3)


# #ar2=np.array([45,135,67,30,48,80,67,18,99,72]) #new price
# print(ar1)
# print(ar2)

# ar3=(ar1==ar2)
# if(np.all(ar3)):
#    print("Same Price")
# else:
#    print(" No same Price")
      
# ar3=(ar1==ar2)
# print(ar3)
# if(np.any(ar3)):
#   print("Some prices are same")
# else:
#   print("No Prices are Same")

# print("Maximum : ",ar1.max())
# print("Minimum : ",ar1.min())
# print("Total : ",ar1.sum())
# print("Mean : ",ar1.mean())

# ar0=np.array(500)
# ar1=np.array([5,13,27,30,48,50,77,88,99,12])
# ar2=np.array([[5,13,27,],[45,15,27,]])
# ar3=np.array([[[5,10,20],[30,40,50]],[[5,10,20],[30,40,50]]])

# ar4=np.array([12.4,33.4,55.6,77.8,88.9,89.9])
# print(ar1.nbytes)

# print(ar1.itemsize)
# print(ar1.size)
# print(ar1.dtype)
# print(ar4.dtype)















#size 
#print(ar3.size)
























# # shape
# print(ar0.shape)
# print(ar0)
# print("---------------------------")
# print(ar1.shape)
# print(ar1)
# print("---------------------------")
# print(ar2.shape)
# print(ar2)
# print("---------------------------")

# print(ar3.shape)
# print(ar3)


#ndim
# print(ar0.ndim)  # 0
# print(ar1.ndim)  #  1
# print(ar2.ndim)  # 2
# print(ar3.ndim) # 3

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *