String operations¶
The numpy.char
module provides a set of vectorized string
operations for arrays of type numpy.string_
or numpy.unicode_
.
All of them are based on the string methods in the Python standard library.
String operations¶
|
Return element-wise string concatenation for two arrays of str or unicode. |
|
Return (a * i), that is string multiple concatenation, element-wise. |
|
Return (a % i), that is pre-Python 2.6 string formatting (iterpolation), element-wise for a pair of array_likes of str or unicode. |
|
Return a copy of a with only the first character of each element capitalized. |
|
Return a copy of a with its elements centered in a string of length width. |
|
Calls str.decode element-wise. |
|
Calls str.encode element-wise. |
|
Return a copy of each string element where all tab characters are replaced by one or more spaces. |
|
Return a string which is the concatenation of the strings in the sequence seq. |
|
Return an array with the elements of a left-justified in a string of length width. |
|
Return an array with the elements converted to lowercase. |
|
For each element in a, return a copy with the leading characters removed. |
|
Partition each element in a around sep. |
|
For each element in a, return a copy of the string with all occurrences of substring old replaced by new. |
|
Return an array with the elements of a right-justified in a string of length width. |
|
Partition (split) each element around the right-most separator. |
|
For each element in a, return a list of the words in the string, using sep as the delimiter string. |
|
For each element in a, return a copy with the trailing characters removed. |
|
For each element in a, return a list of the words in the string, using sep as the delimiter string. |
|
For each element in a, return a list of the lines in the element, breaking at line boundaries. |
|
For each element in a, return a copy with the leading and trailing characters removed. |
|
Return element-wise a copy of the string with uppercase characters converted to lowercase and vice versa. |
|
Return element-wise title cased version of string or unicode. |
|
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. |
|
Return an array with the elements converted to uppercase. |
|
Return the numeric string left-filled with zeros |
Comparison¶
Unlike the standard numpy comparison operators, the ones in the char module strip trailing whitespace characters before performing the comparison.
|
Return (x1 == x2) element-wise. |
|
Return (x1 != x2) element-wise. |
|
Return (x1 >= x2) element-wise. |
|
Return (x1 <= x2) element-wise. |
|
Return (x1 > x2) element-wise. |
|
Return (x1 < x2) element-wise. |
|
Performs element-wise comparison of two string arrays using the comparison operator specified by cmp_op. |
String information¶
|
Returns an array with the number of non-overlapping occurrences of substring sub in the range [start, end]. |
|
Returns a boolean array which is True where the string element in a ends with suffix, otherwise False. |
|
For each element, return the lowest index in the string where substring sub is found. |
|
Like |
|
Returns true for each element if all characters in the string are alphabetic and there is at least one character, false otherwise. |
|
Returns true for each element if all characters in the string are alphanumeric and there is at least one character, false otherwise. |
|
For each element, return True if there are only decimal characters in the element. |
|
Returns true for each element if all characters in the string are digits and there is at least one character, false otherwise. |
|
Returns true for each element if all cased characters in the string are lowercase and there is at least one cased character, false otherwise. |
|
For each element, return True if there are only numeric characters in the element. |
|
Returns true for each element if there are only whitespace characters in the string and there is at least one character, false otherwise. |
|
Returns true for each element if the element is a titlecased string and there is at least one character, false otherwise. |
|
Returns true for each element if all cased characters in the string are uppercase and there is at least one character, false otherwise. |
|
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]. |
|
Like |
|
Returns a boolean array which is True where the string element in a starts with prefix, otherwise False. |
|
Return len(a) element-wise. |
Convenience class¶
|
Create a |
|
Convert the input to a |
|
Provides a convenient view on arrays of string and unicode values. |