What is the difference between flatten and ravel functions in numpy?

import numpy as np
y = np.array(((1,2,3),(4,5,6),(7,8,9)))
OUTPUT:
print(y.flatten())
[1   2   3   4   5   6   7   8   9]
print(y.ravel())
[1   2   3   4   5   6   7   8   9]

Both function return the same list.
Then what is the need of two different functions performing same job.

3 Answers
3

Leave a Comment