If we need to initialize a numpy array with the same value then we use numpy.ndarray.fill (). Suppose we have to create a NumPy array of of length n, each element of which is v. Then we use this function a.fill (v). We don`t need to use loops to initialize the array if we use this
fill () function.
Syntax : ndarray.fill (value)
value: All elements of a will be assigned this value.
Code # 1:
a is: [[1. 1. 1.] [1. 1. 1.] [1. 1. 1.]] After using fill () a is: [[1. 1. 1.] [1. 1. 1.] [1. 1. 1.]]
Code # 2:
a is [0 1 2 3 4] Now a is : [0 0 0 0 0]
Code # 3: numpy.ndarray.fill () also works with multidimensional arrays.
a is: [[0. 0. 0.] [0. 0. 0.] [0. 0. 0.]]
We live in an age of so-called Big Data. We hear terms like data scientist, and there is much talk about analytics and the mining of large amounts of corporate data for tidbits of business value. Ther...
Why this Book? Hadoop has been the base for most of the emerging technologies in today’s big data world. It changed the face of distributed processing by using commodity hardware for large data set...
IRMA is a research-based professional organization dedicated to advancing the concepts and practices of information resource management in modern organizations. The primary purpose of IRMA is to promo...
During 2014, 2015, and 2016, surveys show that among all software developers, those with higher wages are the data engineers, the data scientists, and the data architects. This is because there is ...