Answers for "Python NumPy ndarray flat function Example with 2d array"

0

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 : \n",array )

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

# Using flat() to Print 1D represented array
print("\n1D representation of array : \n ->", array.flat[0:15])
Posted by: Guest on April-21-2022

Python Answers by Framework

Browse Popular Code Answers by Language