Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Delete #row #text #pandas
ADD COMMENT
Topic
Name
4+4 =