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 read file between two strings 
Python :: streamlit format_func example 
Python :: pandas iter groups 
Python :: sns.savefig 
Python :: NumPy left_shift Syntax 
Python :: python logging levels 
Python :: transform dictionary keys python 
Python :: a star search algorithm python code 
Python :: python combinations function 
Python :: calculate the surface area of a cylinder python 
Python :: numpy percentile 
Python :: how do i get auth user model dynamically in django? 
Python :: numpy concatenate arrays 
Python :: get image image memeory size in url inpyton requests 
Python :: sort decreasing python 
Python :: pd calculations between columns 
Python :: how to create tupple in python 
Python :: Python use number twice without variable 
Python :: how to block empty space python login 
Python :: python string to lowercase 
Python :: input a number and print even numbers up to that number in python 
Python :: color module python 
Python :: enumerate word python 
Python :: pandas select multiple columns 
Python :: state capitals python 
Python :: python - extract min and max values per each column name 
Python :: python sh command 
Python :: not equal to in python 
Python :: Examples of os.makedirs() method 
Python :: how to take an input in python 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =