String functionality — NumPy v2.2 Manual (original) (raw)
The numpy.strings module provides a set of universal functions operating on arrays of type numpy.str_ or numpy.bytes_. For example
np.strings.add(["num", "doc"], ["py", "umentation"]) array(['numpy', 'documentation'], dtype='<U13')
These universal functions are also used in numpy.char, which provides the numpy.char.chararray array subclass, in order for those routines to get the performance benefits as well.
Note
Prior to NumPy 2.0, all string functionality was in numpy.char, which only operated on fixed-width strings. That module will not be getting updates and will be deprecated at some point in the future.
String operations#
Comparison#
The numpy.strings module also exports the comparison universal functions that can now operate on string arrays as well.