Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas get rows string in column

# Get all rows that contain a substring
df[df[column_name].str.contains(substring)]

# Get all rows that do NOT contain a substring
df[~df[column_name].str.contains(substring)]
  
# Get all rows that contain one substring OR another substring
df[df[column_name].str.contains(substring1|substring2)]

# Ignore NaN values
df[df[column_name].str.contains(substring, na=False)]
 
PREVIOUS NEXT
Tagged: #pandas #rows #string #column
ADD COMMENT
Topic
Name
7+8 =