liveBook · Manning

Text

As explained in Pandas Workout: 200 exercises to make you a stronger data analyst

Textual data consists of character-based values representing words, phrases, or other written content rather than numeric quantities.

Textual data includes usernames, product names, sales regions, business units, ticker symbols, and company names. It may drive analysis, prepare data for text-based machine learning, or describe and categorize numerical records. section 9.0

Pandas stores text using Python string objects or its pandas-specific string class rather than NumPy character arrays. The str accessor exposes string methods on each Series and returns a new Series that can replace, supplement, or form a new column. section 9.0

Common text operations turn written values into analytical signals:

  • Measure values with str.len(), test character content with str.isdigit(), and locate matching text with str.contains(). section 9.0

Filter words by their contents

For s = Series('this is a test 123 456'.split()), s.str.len() returns each word's length, while s.loc[s.str.isdigit()] selects 123 and 456. A pattern such as s.str.contains('[ae]') produces a Boolean mask for words containing either a or e.

How Pandas Workout: 200 exercises to make you a stronger data analyst covers it

How deep it goes
Explains storage types, the str accessor, returned Series, common methods, and custom functions without detailing string-class internals.
Examples
Uses usernames, product names, regions, business units, ticker symbols, company names, and split words such as test, 123, and 456.
What you can do after
Apply it via pandas' str accessor to measure, classify, search, replace, expand, and encode text in Series and data frames.
How it connects
Connects textual data with pandas, NumPy, Python strings, Series, data frames, categorical data, and text-based machine learning.

Also explained in

Compare how 3 books explain text →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pandas Workout: 200 exercises to make you a stronger data analyst. The section links point to the parts of the book it draws on.