[Numpy-discussion] String accessor methods
toddrjen at gmail.com
Sat Mar 6 09:44:17 EST 2021
Currently. working with strings in numpy is not very convenient. You have
to use a separate set of functions in a separate namespace, and those
functions are relatively limited and poorly-documented.
A solution several other projects, including pandas  and xarray ,
have found are string accessor methods. These are a set of methods attached
to a `str` attribute of the class. These have the advantage that they are
always available and have a well-defined object they operate on. On
non-str dtypes, it would raise an exception.
This would also provide a standardized set of methods and behaviors that
are part of the numpy api that other classes could depend on.
An example would be something like this:
>>> mystr = np.array(["test first", "test second", "test third"])
array(['Test First', 'Test Second', 'Test Third'], dtype='<U11')
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion