Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

remove rows from pandas dataframe that have text

df[df.columnName != 'text']
Comment

Delete row if contains certain text pandas

# importing the library
import pandas as pd
  
# Dataframe
df = pd.DataFrame({'team': ['Team 1', 'Team 1', 'Team 2',
                            'Team 3', 'Team 2', 'Team 3'],
                   'Subject': ['Math', 'Science', 'Science', 
                               'Math', 'Science', 'Math'],
                   'points': [10, 8, 10, 6, 6, 5]})
  
# Dropping the team 1
df = df[df["team"].str.contains("Team 1") == False]
  
df
Comment

PREVIOUS NEXT
Code Example
Python :: merge and join dataframes with pandas in python 
Python :: python dictionary get key by value 
Python :: check pandas version 
Python :: python find closest lower value in list 
Python :: reset django database 
Python :: how to replace first line of a textfile python 
Python :: descending python dataframe df 
Python :: using tqdm in for loop 
Python :: list to sentence python 
Python :: getting multiple selected value django 
Python :: Read XML file to Pandas DataFrame 
Python :: python generate id 
Python :: describe function in pandas 
Python :: save dataframe to a csv local file pyspark 
Python :: register model in admin django 
Python :: generate a random number in python between 0 and 1 
Python :: numpy drop duplicates 
Python :: open file python 
Python :: erase % sign in row pandas 
Python :: install python packages behind proxy 
Python :: python path zsh mac 
Python :: tkinter frame example 
Python :: python join with int 
Python :: django query field is null 
Python :: python break long string multiple lines 
Python :: move one column value down by one column in pandas 
Python :: print only numbers from string python 
Python :: how to find total no of nan values in pandas 
Python :: check if string is empty python 
Python :: Dropping NaN in dataframe 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =