Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python NumPy ndarray flat function Example with 2d array

# welcome to softhunt.net
# Python Program illustrating
# working of ndarray.flat()

import numpy as np

# Working on 1D iteration of 2D array
array = np.arange(15).reshape(5, 3)
print("2D array : 
",array )

# Using flat() : 1D iterator over range
print("
Using Array : ", array.flat[2:6])

# Using flat() to Print 1D represented array
print("
1D representation of array : 
 ->", array.flat[0:15])
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Python #NumPy #ndarray #flat #function #Example #array
ADD COMMENT
Topic
Name
9+3 =