Articles → NUMPY → Broadcast Capability Of An Array In Numpy

Broadcast Capability Of An Array In Numpy






Example




import numpy as np

arr = np.arange(0,10)

# print array
print("Before change", arr)

#Broadcast
arr[0:2] = 200

# print array
print("After change", arr)




Picture showing the output of broadcast capability of an array in NumPy
Click to Enlarge




Changing The Value Of All The Elements In One Go




import numpy as np


arr = np.arange(0,10)

arr[:] = 100

# print array
print(arr)




Picture showing the output of updating all values in array in one go
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, March 28, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250