What is the difference between flatten and ravel functions in numpy?
Asked 07 September, 2021
Viewed 2.6K times
  • 54
Votes
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 Answer