How to convert numpy object array into str/unicode array? How to convert numpy object array into str/unicode array? numpy numpy

How to convert numpy object array into str/unicode array?


I know this is an old question but in case anyone comes across it and is looking for an answer, try

c = a.astype('U')

and you should get the result you expect:

c = array([u'abc', u'12345'], dtype='<U5')


At least in Python 3.5 Jupyter 4 I can use:

a=np.array([u'12345',u'abc'],dtype=object)b=a.astype(str)b

works just fine for me and returns:

array(['12345', 'abc'],dtype='<U5')