The numpy.char module provides a set of vectorized string operations for arrays of type numpy.str_ or numpy.bytes_. All of them are based on the string methods in the Python standard library.
numpy.char
numpy.str_
numpy.bytes_
add(x1, x2)
add
Return element-wise string concatenation for two arrays of str or unicode.
multiply(a, i)
multiply
Return (a * i), that is string multiple concatenation, element-wise.
mod(a, values)
mod
Return (a % i), that is pre-Python 2.6 string formatting (interpolation), element-wise for a pair of array_likes of str or unicode.
capitalize(a)
capitalize
Return a copy of a with only the first character of each element capitalized.
center(a, width[, fillchar])
center
Return a copy of a with its elements centered in a string of length width.
decode(a[, encoding, errors])
decode
Calls str.decode element-wise.
encode(a[, encoding, errors])
encode
Calls str.encode element-wise.
expandtabs(a[, tabsize])
expandtabs
Return a copy of each string element where all tab characters are replaced by one or more spaces.
join(sep, seq)
join
Return a string which is the concatenation of the strings in the sequence seq.
ljust(a, width[, fillchar])
ljust
Return an array with the elements of a left-justified in a string of length width.
lower(a)
lower
Return an array with the elements converted to lowercase.
lstrip(a[, chars])
lstrip
For each element in a, return a copy with the leading characters removed.
partition(a, sep)
partition
Partition each element in a around sep.
replace(a, old, new[, count])
replace
For each element in a, return a copy of the string with all occurrences of substring old replaced by new.
rjust(a, width[, fillchar])
rjust
Return an array with the elements of a right-justified in a string of length width.
rpartition(a, sep)
rpartition
Partition (split) each element around the right-most separator.
rsplit(a[, sep, maxsplit])
rsplit
For each element in a, return a list of the words in the string, using sep as the delimiter string.
rstrip(a[, chars])
rstrip
For each element in a, return a copy with the trailing characters removed.
split(a[, sep, maxsplit])
split
splitlines(a[, keepends])
splitlines
For each element in a, return a list of the lines in the element, breaking at line boundaries.
strip(a[, chars])
strip
For each element in a, return a copy with the leading and trailing characters removed.
swapcase(a)
swapcase
Return element-wise a copy of the string with uppercase characters converted to lowercase and vice versa.
title(a)
title
Return element-wise title cased version of string or unicode.
translate(a, table[, deletechars])
translate
For each element in a, return a copy of the string where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table.
upper(a)
upper
Return an array with the elements converted to uppercase.
zfill(a, width)
zfill
Return the numeric string left-filled with zeros
Unlike the standard numpy comparison operators, the ones in the char module strip trailing whitespace characters before performing the comparison.
equal(x1, x2)
equal
Return (x1 == x2) element-wise.
not_equal(x1, x2)
not_equal
Return (x1 != x2) element-wise.
greater_equal(x1, x2)
greater_equal
Return (x1 >= x2) element-wise.
less_equal(x1, x2)
less_equal
Return (x1 <= x2) element-wise.
greater(x1, x2)
greater
Return (x1 > x2) element-wise.
less(x1, x2)
less
Return (x1 < x2) element-wise.
compare_chararrays(a, b, cmp_op, rstrip)
compare_chararrays
Performs element-wise comparison of two string arrays using the comparison operator specified by cmp_op.
count(a, sub[, start, end])
count
Returns an array with the number of non-overlapping occurrences of substring sub in the range [start, end].
endswith(a, suffix[, start, end])
endswith
Returns a boolean array which is True where the string element in a ends with suffix, otherwise False.
find(a, sub[, start, end])
find
For each element, return the lowest index in the string where substring sub is found.
index(a, sub[, start, end])
index
Like find, but raises ValueError when the substring is not found.
isalpha(a)
isalpha
Returns true for each element if all characters in the string are alphabetic and there is at least one character, false otherwise.
isalnum(a)
isalnum
Returns true for each element if all characters in the string are alphanumeric and there is at least one character, false otherwise.
isdecimal(a)
isdecimal
For each element, return True if there are only decimal characters in the element.
isdigit(a)
isdigit
Returns true for each element if all characters in the string are digits and there is at least one character, false otherwise.
islower(a)
islower
Returns true for each element if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.
isnumeric(a)
isnumeric
For each element, return True if there are only numeric characters in the element.
isspace(a)
isspace
Returns true for each element if there are only whitespace characters in the string and there is at least one character, false otherwise.
istitle(a)
istitle
Returns true for each element if the element is a titlecased string and there is at least one character, false otherwise.
isupper(a)
isupper
Returns true for each element if all cased characters in the string are uppercase and there is at least one character, false otherwise.
rfind(a, sub[, start, end])
rfind
For each element in a, return the highest index in the string where substring sub is found, such that sub is contained within [start, end].
rindex(a, sub[, start, end])
rindex
Like rfind, but raises ValueError when the substring sub is not found.
startswith(a, prefix[, start, end])
startswith
Returns a boolean array which is True where the string element in a starts with prefix, otherwise False.
str_len(a)
str_len
Return len(a) element-wise.
array(obj[, itemsize, copy, unicode, order])
array
Create a chararray.
chararray
asarray(obj[, itemsize, unicode, order])
asarray
Convert the input to a chararray, copying the data only if necessary.
chararray(shape[, itemsize, unicode, …])
Provides a convenient view on arrays of string and unicode values.