+ 1
Ravel() in python
What is the function and what types its used for?
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
+ 1
Valmob101 can i use ravel() fot list, dict , set, range and tuple?
+ 1
Valmob101
What is " ndarray"?
+ 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
0
Petr only if the object is ndarray. You can convert it as:
numpy.array(iterable)
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.
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