display array of odd rows and even columns in numpy
>>> x[:, 1::2]
array([[ 2, 4],
[ 7, 9],
[12, 14],
[17, 19]])
display array of odd rows and even columns in numpy
>>> x[:, 1::2]
array([[ 2, 4],
[ 7, 9],
[12, 14],
[17, 19]])
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)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us