Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python slicing nested list

# 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 :: what if we multiply a string in python 
Python :: what does .shape do in python 
Python :: column names pandas 
Python :: how to unpivot dataframe pandas 
Python :: path in string python 
Python :: how to send file using socket in python 
Python :: Python Program to Find Armstrong Number in an Interval 
Python :: python cmd exec 
Python :: outlier removal 
Python :: drop na dataframe 
Python :: count characters in string python 
Python :: python check if key exists 
Python :: python stop while loop after time 
Python :: pandas df filter by time hour 
Python :: how to make a use of list in python to make your own length function 
Python :: wait driver selenium 
Python :: first and last digit codechef solution 
Python :: python get attributes of object 
Python :: current date and time into timestamp 
Python :: pd.dataframe initial columns 
Python :: python datetime format string 
Python :: Calculate Euclidean Distance in Python using distance.euclidean() 
Python :: python how to remove item from list 
Python :: Python how to compile to exe file 
Python :: check if a string is float python 
Python :: zero crossing rate python 
Python :: python num2words installation 
Python :: python list of dictionary unique 
Python :: suppress python 
Python :: nested loop in list comprehension 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =