📜  NumPy-字符串函数

📅  最后修改于: 2020-11-08 07:37:41             🧑  作者: Mango


以下函数用于对dtype numpy.string_或numpy.unicode_的数组执行向量化字符串操作。它们基于Python内置库中的标准字符串函数。

Sr.No. Function & Description
1 add()

Returns element-wise string concatenation for two arrays of str or Unicode

2 multiply()

Returns the string with multiple concatenation, element-wise

3 center()

Returns a copy of the given string with elements centered in a string of specified length

4 capitalize()

Returns a copy of the string with only the first character capitalized

5 title()

Returns the element-wise title cased version of the string or unicode

6 lower()

Returns an array with the elements converted to lowercase

7 upper()

Returns an array with the elements converted to uppercase

8 split()

Returns a list of the words in the string, using separatordelimiter

9 splitlines()

Returns a list of the lines in the element, breaking at the line boundaries

10 strip()

Returns a copy with the leading and trailing characters removed

11 join()

Returns a string which is the concatenation of the strings in the sequence

12 replace()

Returns a copy of the string with all occurrences of substring replaced by the new string

13 decode()

Calls str.decode element-wise

14 encode()

Calls str.encode element-wise

这些函数在字符数组类(numpy.char)中定义。较早的Numarray软件包包含chararray类。 numpy.char类中的以上函数在执行矢量化字符串操作时很有用。