Legacy fixed-width string functionality — NumPy v2.2 Manual (original) (raw)

Legacy

This submodule is considered legacy and will no longer receive updates. This could also mean it will be removed in future NumPy versions. The string operations in this module, as well as the numpy.char.chararrayclass, are planned to be deprecated in the future. Use numpy.stringsinstead.

The numpy.char module provides a set of vectorized string operations for arrays of type numpy.str_ or numpy.bytes_. For example

import numpy as np np.char.capitalize(["python", "numpy"]) array(['Python', 'Numpy'], dtype='<U6') np.char.add(["num", "doc"], ["py", "umentation"]) array(['numpy', 'documentation'], dtype='<U13')

The methods in this module are based on the methods in string

String operations#

Comparison#

Unlike the standard numpy comparison operators, the ones in the _char_module strip trailing whitespace characters before performing the comparison.

String information#

Convenience class#