pandas/string-ops

String Operations

Vectorized string methods for Series

pandas
string
text

Command

df["col"].str

Explanation

The .str accessor provides string manipulation functions.

Examples

Convert strings to lowercase

df["col"].str.lower()

Check if strings contain pattern

df["col"].str.contains("pattern")

Replace substrings

df["col"].str.replace("old", "new")