+ 1

Ravel() in python

What is the function and what types its used for?

24th May 2020, 4:24 PM
Petr
7 Answers
+ 2
It is used to flatten the array: syntax: numpy.ravel(input_array) OR input_array.ravel() E.g https://code.sololearn.com/cXGcoRF88psR/?ref=app
24th May 2020, 4:35 PM
Lerninn
+ 1
Valmob101 can i use ravel() fot list, dict , set, range and tuple?
24th May 2020, 4:37 PM
Petr
+ 1
Valmob101 What is " ndarray"?
24th May 2020, 4:41 PM
Petr
+ 1
Valmob101 ok. But its not clear enough. For example: x=np.array([[1,2,3],[4,5,6]]) Why are answers for 1) np.ravel(x, order="F") And 2) np.ravel(x,order="A") will be different? What is the second argument for this function
24th May 2020, 4:52 PM
Petr
0
Petr only if the object is ndarray. You can convert it as: numpy.array(iterable)
24th May 2020, 4:40 PM
Lerninn
0
Petr ndarray is a type of list specially designed for numpy. It is has same property as list but has many methods and also faster.
24th May 2020, 4:44 PM
Lerninn
0
Petr the second argument takes as order. Fortran style or c style. Fortran style simple means column major, means, if an array is: [ 1 2 3 ] [ 4 5 6 ] And if it is sorted in fstyle, the columns will be transposed(rotate). [ 1 4 ] [ 2 5 ] [ 3 6 ] Cstyle for row major and its output will be opposite of the previous array or same as 1st one
24th May 2020, 5:02 PM
Lerninn