I have now a fixed-size string numpy array:
import numpy as np
str_arr = np.array(['test1', 'test2'], dtype='<U5')
str_arr[0] = 'longer_string'
print(str_arr)
And it returns
['longe' 'test2']
I'd like to remove this limit. Would there be a way to do so? Below is an example of my failed attempt:
str_arr_copy = str_arr.astype(str)
str_arr_copy[0] = 'longer_string'
print(str_arr_copy)
And it doesn't help at all.
Thank you!
str_arr.astype('U100')gives you more space, but doesn't eliminate the limit. For this work a regular list is probably better.