ndarray.__array__() method, we can create a new array of our own by setting the parameter as dtype, strong> and we can get a copy of the array that does not change the data element of the original array if we change any element in the new one.
Syntax: ndarray .__ array __ ()
- Returns either a new reference to self if dtype is not given
- New array of provided data type if dtype is different from the current dtype of the array.
Example # 1:
In this example, we we can see that we are changing the dtype of the new array simply using
ndarray .__ array __ () .
< b> Output:
[1. 2. 3. 4. 5.]
Example # 2:
[[1 2 3 4 5] [6 5 4 3 2]]
Cracking the Coding Interview PDF: 189 Programming Questions and Solutions, 6th Edition. I am not a recruiter. I am a software engineer. And as such, I know what it's like to be asked to create ing...
As information protection continues to be a growing concern for businesses today, IT security certifications have become highly desirable, even as the number of certifications has grown. Now you can s...
A Problem-Solver’s Guide to Building Real-World Intelligent Systems. Data is the new oil and Machine Learning is a powerful concept and framework for making the best out of it. In this age of aut...
Acquire and analyze data from all corners of the social web with Python. This book is for intermediate Python developers who want to engage with the use of public APIs to collect data from social m...