Answers for "odd rows and even columns of array using numpy"

0

display array of odd rows and even columns in numpy

>>> x[:, 1::2]
array([[ 2,  4],
       [ 7,  9],
       [12, 14],
       [17, 19]])
Posted by: Guest on June-25-2020
0

Return array of odd rows and even columns from array using numpy

import numpy

sampleArray = numpy.array([[3 ,6, 9, 12], [15 ,18, 21, 24], 
[27 ,30, 33, 36], [39 ,42, 45, 48], [51 ,54, 57, 60]]) 
print("Printing Input Array")
print(sampleArray)

print("n Printing array of odd rows and even columns")
newArray = sampleArray[::2, 1::2]
print(newArray)
Posted by: Guest on January-13-2022

Python Answers by Framework

Browse Popular Code Answers by Language