How to split text to columns with Pandas and Python in a Jupyter Notebook

Documentation for splitting a text column into two columns in a Pandas DataFrame, with Python and Jupyter Notebook

David Allen
4 min readMar 17, 2022

--

Spreadsheet cowboys will know that a very common data cleaning operation is to split text to columns.

Data Analysts who are new to Python, Pandas, and Jupyter notebooks will appreciate the ease of executing this same task with this new Data Analysis stack.

Let’s get started.

Table of Contents

  1. Set up notebook
  2. Import data
  3. Split-text-to-columns

Step 1: Set up notebook

First, let’s get a new notebook open and import pandas:

import pandas as pd

Dang, that was easy.

Step 2: Import some data

Let’s get some data and then split some text to columns. What do you say?

For this tutorial, I just wanted a CSV with some date values in it so that we could split the date value (for example: 2019–05–10) into year, month, and day.

--

--

David Allen

Documentation and tutorials on Python, Pandas, Jupyter Notebook, and Data Analysis.