- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python - Remove positional rows
When it is required to remove positional rows, a simple iteration and the ‘pop’ method is used.
Below is a demonstration of the same
my_list = [[31, 42, 2], [1, 73, 29], [51, 3, 11], [0, 3, 51], [17, 3, 21], [1, 71, 10], [0, 81, 92]] print("The list is :") print(my_list) my_index_list = [1, 2, 5] for index in my_index_list[::-1]: my_list.pop(index) print("The output is :") print(my_list)
The list is : [[31, 42, 2], [1, 73, 29], [51, 3, 11], [0, 3, 51], [17, 3, 21], [1, 71, 10], [0, 81, 92]] The output is : [[31, 42, 2], [0, 3, 51], [17, 3, 21], [0, 81, 92]]
A nested list is defined and is displayed on the console.
Another list with integer values is defined.
This list is iterated over and reversed.
Every index is deleted using the ‘pop’ method.
This is the output which is displayed on the console.
- Python – Remove rows with Numbers
- MongoDB pull with positional operator?
- Remove similar element rows in tuple Matrix in Python
- Python – Remove Rows for similar Kth column element
- Python program to remove rows with duplicate element in Matrix
- How to use one or more same positional arguments in Python?
- Using positional operator with hierarchies in MongoDB?
- Find number of Positional Elements in C++
- Remove new line characters from rows in MySQL?
- Write a program in Python to remove first duplicate rows in a given dataframe
- How to remove all rows having NA in R?
- How to remove empty rows from an R data frame?
- Remove specific fields/ rows and show other records in MySQL?
- How to remove rows that contain NAs in R matrix?
- How to remove last few rows from an R data frame?