October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Split a Pandas Column by a Delimiter

Use pandas Series.str.split with expand=True to split a string column into columns, with options for literal delimiters, limited splits, and uneven rows.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Series.str.split(delimiter, expand=True) to turn a pandas string column into separate columns. Set n= if you want to limit how many delimiters are used, and set regex=False when a multi-character separator should be treated literally.

Split a column into separate columns

Call the string accessor on the Series and pass expand=True. Replace the comma below with the delimiter in your data:

As an Amazon Associate I earn from qualifying purchases.

parts = df["column"].str.split(",", expand=True)

parts is a DataFrame with one column for each resulting piece. To replace the original column, inspect the output first, then assign meaningful names that match its number of columns:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
parts = df["column"].str.split(",", expand=True)
parts.columns = ["first", "second"]
df[["first", "second"]] = parts

This naming example assumes the split produces exactly two columns; adjust the names to the actual output shape. Without expand=True, str.split returns lists in a Series rather than separate DataFrame columns. If you omit the delimiter, pandas splits on whitespace.

Choose how many delimiters to use

By default, n=-1 means split at every occurrence. Use a positive n to limit the number of splits, starting from the left:

df["column"].str.split(",", n=1, expand=True)

This makes at most one split per value, leaving any later commas in the final piece. n=None and n=0 also mean split at all occurrences.

Make literal and regex separators explicit

With the default regex=None, pandas treats a one-character pattern as a literal separator, but a pattern longer than one character as a regular expression. For a multi-character delimiter that should be matched exactly, set regex=False:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
df["column"].str.split("::", regex=False, expand=True)

Use regex=True when the pattern is intentionally a regular expression. In that case, escape regex metacharacters that should be matched literally.

Know what happens with uneven or missing values

Expanded results have a rectangular shape. When some rows split into fewer pieces than others, pandas pads the shorter results with missing values. Missing input values remain missing in the expanded output; they are not converted into empty strings.

Use a different method for only the first or last separator

Split around the first separator

Series.str.partition returns three pieces: the text before the separator, the separator itself, and the text after it. It is useful when you want to preserve the remainder as one piece.

Split from the right

Use Series.str.rsplit(delimiter, n=1, expand=True) to split at most once, working from the end of each value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose the output shape

  • Separate columns: use str.split(..., expand=True).
  • Lists in one Series: omit expand=True.
  • Rows from list-like values: use Series.explode after splitting; this reshapes the data into long format rather than creating columns.

See the pandas documentation for Series.str.split, the working with text guide, Series.str.partition, Series.str.rsplit, and Series.explode.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.