Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

display array of odd rows and even columns in numpy

>>> x[:, 1::2]
array([[ 2,  4],
       [ 7,  9],
       [12, 14],
       [17, 19]])
Comment

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("
 Printing array of odd rows and even columns")
newArray = sampleArray[::2, 1::2]
print(newArray)
Comment

PREVIOUS NEXT
Code Example
Python :: python isinstance list 
Python :: progress bar python 
Python :: how to check if item is in the variable python 
Python :: np.zeros((3,3)) 
Python :: python program to find ascii value of character 
Python :: python how to add up all numbers in a list 
Python :: install python 3.8 
Python :: json decode py 
Python :: python opencv subtract two images 
Python :: kruskal python implementation 
Python :: python 3d array 
Python :: how to check if an element is in a list python 
Python :: underscore in python 
Python :: voice translate python 
Python :: python pause function 
Python :: django slug int url mapping 
Python :: how to extract words from string in python 
Python :: dataframe in python 
Python :: filter django or 
Python :: python cv2 imwrite 
Python :: How to rotate the 2D vector by degree in Python: 
Python :: print schema in pandas dataframe 
Python :: open csv from url python 
Python :: detect character in string python 
Python :: how to play and stop music python 
Python :: how to assign a new value in a column in pandas dataframe 
Python :: how to view all attributes and methods of an object python 
Python :: python create a grid of points 
Python :: python print without new lines 
Python :: decimal to octal in python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =