String (.str) Accessor#
Access string methods on Series with string data via .str.
Example#
import pandasCore as pd
s = pd.Series(['foo', 'bar', 'baz'])
s.str.upper() # ['FOO', 'BAR', 'BAZ']
s.str.contains('a') # [False, True, True]
Methods#
Method |
Description |
|---|---|
upper() |
Convert to uppercase |
lower() |
Convert to lowercase |
title() |
Convert to title case |
capitalize() |
Capitalize first letter |
swapcase() |
Swap case |
strip() |
Strip whitespace |
lstrip() |
Strip left whitespace |
rstrip() |
Strip right whitespace |
len() |
String length |
contains(pat) |
Check if contains pattern |
startswith(pat) |
Check if starts with pattern |
endswith(pat) |
Check if ends with pattern |
replace(pat, repl) |
Replace pattern |
split(pat) |
Split by pattern |
join(sep) |
Join with separator |
extract(pat) |
Extract groups from pattern |
findall(pat) |
Find all occurrences |
get(i) |
Get character at position |
slice(start, stop) |
Slice strings |
cat(others) |
Concatenate strings |
repeat(n) |
Repeat strings |
pad(width) |
Pad strings |
center(width) |
Center strings |
zfill(width) |
Zero-fill strings |