Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

drop rows in list pandas

rows = df.index[[0,2]]

df.drop(rows, inplace=True)
Comment

pandas drop row from a list of vlaue

df = df[~df.datecolumn.isin(a)]
Comment

remove rows from pandas

df = df[df["column_name"].isin([0, 1, 3, 4])]
# into isin we put the value we want to mantain
Comment

Drop a list of rows from Pandas

df.drop(df.index[[1,3,6,7]])
Comment

pandas drop rows

 current table:
  Modules	Subjects
0	DSM020	Data programming in Python
1	DSM030	Mathematics and statistics
2	DSM040	Machine learning
3	DSM010	Big data analysis
4	DSM050	Data visualisation
5	DSM060	Data science research topics
6	DSM070	Blockchain programming
7	DSM080	Mathematics of financial markets
8	DSM110	R for data science
9	DSM120	Financial data modelling
10	DSM500	Final project
11	DSM100	Artificial 

#dropping rows using indexes
list_of_subjects.drop([2,5,6,8,10,11])

output:
	Modules	Subjects
0	DSM020	Data programming in Python
1	DSM030	Mathematics and statistics
3	DSM010	Big data analysis
4	DSM050	Data visualisation
7	DSM080	Mathematics of financial markets
9	DSM120	Financial data modelling
Comment

PREVIOUS NEXT
Code Example
Python :: clear pygame screen 
Python :: latest django version 
Python :: datetime to int python 
Python :: python import specific excel sheet 
Python :: adaptive thresholding with opencv python 
Python :: how to graph with python 
Python :: django read mesage 
Python :: saving to csv without the index 
Python :: alarm when code finishes 
Python :: pandas describe get mean min max 
Python :: train test validation sklearn 
Python :: combinations python 
Python :: notify2 python example 
Python :: usong brave browser pyhton 
Python :: python swap 0 into 1 and vice versa 
Python :: dict to array of string python 
Python :: drop rows with certain values pandas 
Python :: How to make an simple python client 
Python :: flip pyplot python 
Python :: simple thresholding with OpenCV 
Python :: how to run function on different thread python 
Python :: pandas read csv as strings 
Python :: pygame draw rect syntax 
Python :: matplotlib create histogram edge color 
Python :: rename files in a folder python 
Python :: pyqt display math 
Python :: add percentage column pandas 
Python :: printing a range of no one line in python 
Python :: check if user has manage messages discord.py 
Python :: get the last element of a list python 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =