Pandas String Operations

Pandas String Operations

Pandas String Operations

Pandas String Operations

Methods Similar to Python String Methods

len lower translate islower
ljust upper startswith isupper
rjust find endswith isnumeric
center rfind isalnum isdecimal
zfill index isalpha split
strip rindex isdigit rsplit
rstrip capitalize isspace partition
lstrip swapcase istitle rpartition

Methods Using Regular Expressions

There are several methods that accept regular expressions

Method Description
match Call re.match on each element, returning a Boolean
extract Call re.match on each element, returning matched groups as strings
findall Call re.findall on each element
replace Replace occurrences of pattern with some other string
contains Call re.search on each element, returning a Boolean
count Count occurrences of pattern
split Equivalent to str.split, but accepts regexps
rsplit Equivalent to str.rsplit, but accepts regexps

Methods Using Regular Expressions

Miscellaneous Methods

Method Description
get Index each element
slice Slice each element
slice_replace Replace slice in each element with passed value
cat Concatenate strings
repeat Repeat values
normalize Return Unicode form of string
pad Add whitespace to left, right, or both sides of string
wrap Split long strings into lines with length less than a given width
join Join strings in each element of the Series with passed separator
get_dummies Extract dummy variables as a dataframe

Vectorized Item Access and Slicing

Indicator Variables

Indicator Variables