Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

drop rows with certain values pandas

#to drop rows based on certain condition in a column
import pandas as pd

df = df[df['column']!=1]
Comment

pandas drop rows with value in list

import pandas as pd

a = ['2015-01-01' , '2015-02-01']

df = pd.DataFrame(data={'date':['2015-01-01' , '2015-02-01', '2015-03-01' , '2015-04-01', '2015-05-01' , '2015-06-01']})

print(df)
#         date
#0  2015-01-01
#1  2015-02-01
#2  2015-03-01
#3  2015-04-01
#4  2015-05-01
#5  2015-06-01

df = df[~df['date'].isin(a)]

print(df)
#         date
#2  2015-03-01
#3  2015-04-01
#4  2015-05-01
#5  2015-06-01
Comment

pandas drop row from a list of vlaue

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

PREVIOUS NEXT
Code Example
Python :: python function returns function 
Python :: how to find last index of list in python 
Python :: delete database entry using name django 
Python :: django ModelChoiceField value not id 
Python :: how to play video in colab 
Python :: create pdf from bytes python 
Python :: all pdf in a directory to csv python 
Python :: tower of hanoi python 
Python :: convert text to speech in python 
Python :: print current line number python 
Python :: matplotlib boxplot colors 
Python :: System.Windows.Forms.DataGridView.CurrentRow.get returned null. c# 
Python :: 1d array to one hot 
Python :: clone website 
Python :: python dictionary rename key 
Python :: move column in pandas 
Python :: python web parsing 
Python :: for i 
Python :: max of three numbers in python 
Python :: Adding function to a varieble in python 
Python :: how to change size of turtle in python 
Python :: Origin in CORS_ORIGIN_WHITELIST is missing scheme or netloc 
Python :: know datatype of pandas 
Python :: program to print duplicates from a list of integers in python 
Python :: selenium get cookies python 
Python :: change index of dataframe with list 
Python :: pick a random number from a list in python 
Python :: Accessing elements from a Python Dictionary 
Python :: kivy change window size 
Python :: panda search strings in column 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =