liveBook · Manning

String method

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

Operations provided by the Python string type for inspecting, transforming, and manipulating textual values.

A string method performs an operation on textual values, such as measuring length, testing content, replacing text, or extracting information. In pandas, string methods are applied to a Series through the str accessor and return a new Series that can replace, extend, or accompany the original data. section 9.0

Filter strings containing a target pattern

Given s = Series('this is a test 123 456'.split()), evaluate s.str.contains('[ae]') to obtain a Boolean Series, then use s.loc[s.str.contains('[ae]')] to retain the matching values, such as “a” and “test”.

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

How deep it goes
Explains returned Series, common operations, Boolean filtering, and custom functions without descending into string-object internals.
Examples
Demonstrates lengths, digit tests, pattern matching, Boolean selection, replacement, and one-hot categorical expansion.
What it assumes
Assumes familiarity with pandas Series while teaching string operations and the str accessor for textual columns.
What you can do after
Apply string methods through str, assign returned Series, filter matching values, and create transformed or indicator columns.
How it connects
Connects string methods with pandas Series, DataFrames, regular expressions, categorical data, and custom functions.

Also explained in

Compare how 2 books explain string method →

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.