Answers for "difference between ravel and flatten"

0

difference between ravel and flatten

The question arises here, why are there two numpy functions to do the same task ?

Differences between Flatten() and Ravel()

a.ravel():
(i) Return only reference/view of original array
(ii) If you modify the array you would notice that the value of original array also changes.
(iii) Ravel is faster than flatten() as it does not occupy any memory.
(iv) Ravel is a library-level function.

a.flatten() :
(i) Return copy of original array
(ii) If you modify any value of this array value of original array is not affected.
(iii) Flatten() is comparatively slower than ravel() as it occupies memory.
(iv) Flatten is a method of an ndarray object.
Posted by: Guest on August-25-2021

Code answers related to "difference between ravel and flatten"

Browse Popular Code Answers by Language