Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

delete row from dataframe python

df.drop(df.index[-2])
df.drop(df.index[[3, 4]])
df.drop(['row_1', 'row_2'])
df.drop('column_1', axis=1)
df[df.name != 'cell']
df.reset_index()
Comment

remove rows python

# delete a single row by index value 0
data = data.drop(labels=0, axis=0)

# delete a few specified rows at index values 0, 15, 20.
# Note that the index values do not always align to row numbers.
data = data.drop(labels=[1,15,20], axis=0)

# delete a range of rows - index values 10-20
data = data.drop(labels=range(40, 45), axis=0)

# The labels parameter name can be omitted, and axis is 0 by default
# Shorter versions of the above:
data = data.drop(0)
data = data.drop([0, 15, 20])
data = data.drop(range(10,20))<div class="open_grepper_editor" title="Edit & Save To Grepper"></div>
Comment

dataframe delete row

df.drop(df.index[2])
Comment

drop row pandas

df.drop(index='Row Name', axis=1, inplace=True) 
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

remove rows from dataframe

df.drop(['Cochice', 'Pima'])
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 :: force utf-8 encoding python 
Python :: sqlalchemy check if database exists 
Python :: how to convert png to pdf with python 
Python :: flask debug 
Python :: activate venv enviroment 
Python :: python socket recv timeout 
Python :: clear all python cache 
Python :: Dummy or One Hot Encoding code with pandas 
Python :: converting datetime object format to datetime format python 
Python :: how to compare current date to future date pythono 
Python :: python selenium type in input 
Python :: createview 
Python :: raise an APi error on django rest view 
Python :: natsort python pip install 
Python :: python check numpy arrays equal 
Python :: how to draw a bar graph in python 
Python :: sample datafra,e PYTHON 
Python :: python print do not use scientific notation 
Python :: python writeline file 
Python :: The `.create()` method does not support writable nested fields by default. Write an explicit `.create()` method for serializer `room_api.serializers.roomSerializer`, or set `read_only=True` on nested serializer fields. 
Python :: google colab how to upload a folder 
Python :: check python version conda env 
Python :: creat and active python environment 
Python :: pandas transform date format? 
Python :: tkinter input box 
Python :: python datetime add one week 
Python :: install qt designer python ubuntu 
Python :: how to check if all characters in string are same python 
Python :: get last day of month python 
Python :: create dictionary comprehension python 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =