Skip to main content

ser.str.split()

ser.str.split(pat = None)

Splits each string element in the Series from the beginning, at the specified seperator/delimiter string.

Input:
pat : string or None, default None
String to split on. If not specified, split on whitespace.
Returns:
Returns a Series with each element as a list of strings split from the original string.
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!"


In the default setting, the string is split by whitespace.

comment_ser.str.split()
  • 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!"]


Split the string by specified seperator.

comment_ser.str.split(',')
  • 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!"]