Split column — splitColumn
Split one text column into several columns, by a literal delimiter or by regex capture groups.
Use cases
- Split a full name into
first/last. - Break a code like
A-100into its parts with a regex.
What it does
Splits the source column on the delimiter (or regex capture groups) and writes
one new column per name in into. Rows with fewer parts leave trailing columns null.
Before
| id | full_name |
|---|---|
| 1 | Ada Lovelace |
| 2 | Grace Hopper |
| 3 | Linus Torvalds |
3 rows · 2 cols
After
| id | full_name | firstnew | lastnew |
|---|---|---|---|
| 1 | Ada Lovelace | Ada | Lovelace |
| 2 | Grace Hopper | Grace | Hopper |
| 3 | Linus Torvalds | Linus | Torvalds |
3 rows · 4 cols
Configuration
| Config key | Type | Required | Description |
|---|---|---|---|
column | string | Yes | Text column to split |
mode | string | No | delimiter (default) or regex |
delimiter | string | Conditional | Delimiter to split on (required for delimiter mode) |
pattern | string | Conditional | Regex; capture group 1 → first column, etc. (required for regex mode) |
into | string[] | Yes | Names for the resulting columns, in order |
keep_original | bool | No | Keep the source column (default true) |
Generated Python code
pandas
python
_parts = df_1['full_name'].astype('string').str.split(' ', expand=True)
df_2 = df_1.assign(first=(_parts[0] if 0 in _parts.columns else pd.NA), last=(_parts[1] if 1 in _parts.columns else pd.NA))Polars
python
df_2 = df_1.with_columns([pl.col('full_name').cast(pl.Utf8).str.split(' ').list.get(0, null_on_oob=True).alias('first'), pl.col('full_name').cast(pl.Utf8).str.split(' ').list.get(1, null_on_oob=True).alias('last')])Tips & common mistakes
intonames the outputs in order. In regex mode, capture group 1 fills the first name, group 2 the second, and so on.- Uneven splits leave trailing columns null when a row has fewer parts, including when no row has enough parts. The exported script preserves this behavior for empty inputs as well.
- Set
keep_original: falseto drop the source column after splitting.