1. Home
  2. Data Science
  3. NumPy
  4. What does the np.ravel() function in NumPy do?

Added 24 Feb 2024

What does the np.ravel() function in NumPy do?

  1. Flattens a multi-dimensional array into a 1D array Correct answer
  2. Transposes a multi-dimensional array
  3. Reshapes a multi-dimensional array
  4. Concatenates two arrays along a specified axis

Correct answer

A. Flattens a multi-dimensional array into a 1D array

15 views

MCQSEXAM

Explanation

np.ravel() flattens a multi-dimensional array into a 1-D array. It returns a view of the original data whenever possible, so it is memory-efficient.

flatten() does the same job but always returns a copy.

For more solved questions like this one, see Data Science MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More NumPy MCQs

Practise all NumPy MCQs

Similar MCQs