Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python NumPy ndarray flat function Example

# 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 )

# All elements set to 1
array.flat = 1
print("
All Values set to 1 : 
", array)

array.flat[3:6] = 8
array.flat[8:10] = 9
print("Changing values in a range : 
", array)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Python #NumPy #ndarray #flat #function #Example
ADD COMMENT
Topic
Name
7+6 =