Search
 
SCRIPT & CODE EXAMPLE
 

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)]
Comment

PREVIOUS NEXT
Code Example
Python :: get stats from list python 
Python :: check filed exist in object python 
Python :: how to add percentage in pie chart in python 
Python :: tensorflow version check 
Python :: imshow grayscale 
Python :: matplotlib figsize 
Python :: python get stack trace 
Python :: python iterate directory 
Python :: python install ffpyplayer 
Python :: python pygame screen example 
Python :: use incognito in selenium webdriver 
Python :: tuple negative indexing in python 
Python :: save an image in python as grayscale cv2 
Python :: cv2 crop image 
Python :: check 32 or 64 bit python 
Python :: extended euclidean python 
Python :: color to black and white cv2 
Python :: convert date time to date pandas 
Python :: save clipboard data win32clipboard python 
Python :: read shp in python 
Python :: module not found not module name channels in python 
Python :: how to read video in opencv python 
Python :: python elif invalid syntax 
Python :: django reset database 
Python :: get_object_or_404 
Python :: pyspark import f 
Python :: how do i print the entire array pthon jupyter 
Python :: pandas dataframe set datetime index 
Python :: pipenv freeze requirements.txt 
Python :: python replace space with underscore 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =