Skip to main content

ser.str.contains()

ser.str.contains(substring)

Tests if a substring is contained within each element of the Series.

Input:
substring : string
String to search for.
Returns:
Returns a Series with a boolean value for each element expressing if each element contained the inputted substring.
Return Type:
Series

comment_ser = pets.get('Owner_Comment')
comment_ser
  • 0" There are no bad dogs, only bad owners."
  • 1"My best birthday present ever!!!"
  • 2"****All you need is love and a cat.****"
  • 3"Love is a wet nose and a wagging tail."
  • 4"Be the person your dog thinks you are."
  • 5"No, thank you!"
  • 6"No, thank you!"
  • 7"No, thank you!"
comment_ser.str.contains('dog')
  • 0True
  • 1False
  • 2False
  • 3False
  • 4True
  • 5False
  • 6False
  • 7False