Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python NumPy ravel function example Showing ordering manipulation

# Welcome to softhunt.net
# Python Program illustrating
# numpy.ravel() method

import numpy as np

array = np.arange(15).reshape(5, 3)
print("Original array : 
", array)

# Output comes like [ 0 1 2 ..., 12 13 14]
# as it is a long output, so it is the way of
# showing output in Python

# About :
print("
About numpy.ravel() : ", array.ravel)

print("
numpy.ravel() : ", array.ravel())

# Maintaining both 'A' and 'F' order
print("
Maintains A Order : ", array.ravel(order = 'A'))

# K-order preserving the ordering
# 'K' means that is neither 'A' nor 'F'
array2 = np.arange(12).reshape(2,3,2).swapaxes(1,2)
print("
array2 
", array2)
print("
Maintains A Order : ", array2.ravel(order = 'K'))
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Python #NumPy #ravel #function #Showing #ordering #manipulation
ADD COMMENT
Topic
Name
6+7 =