Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python slicing multi dimensional array

# Basic syntax:
[your_list[i][start_col : end_col] for i in range(start_row, end_row)]

# Example usage:
your_list = [[1, 2, 3, 4, 5],[6, 7, 8, 9, 10],[11, 12, 13, 14, 15]]
# obtain rows 0-1 (inclusive) and cols 2-3 (inclusive)
[your_list[i][2:4] for i in range(0,2)]
--> [[3, 4], [8, 9]]
Comment

PREVIOUS NEXT
Code Example
Python :: numpy delete column 
Python :: know datatype of pandas 
Python :: python find duplicates in string 
Python :: count number of each item in list python 
Python :: check python version 
Python :: how to merge two dictionaries in python 
Python :: how to calculate z score in python 
Python :: check remote port is open or not using python 
Python :: add column to existing numpy array 
Python :: matplotlib point labels 
Python :: python move a file from one folder to another 
Python :: python challenges 
Python :: delete tuple from list python 
Python :: python foreach list 
Python :: create app in django 
Python :: heatmap of pandas dataframe with seaborn 
Python :: python pyowm 
Python :: change default port django 
Python :: management commands django 
Python :: pandas column filter 
Python :: set type of column pandas 
Python :: python list all methods of a class 
Python :: how to execute bash commands in python script 
Python :: how to install packages inside thepython script 
Python :: virtualenv specify python version 
Python :: convert timedelta to int 
Python :: flask debugtoolbar 
Python :: django install 
Python :: with suppress python 
Python :: how to declare a variable in python 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =