Jun-07-2020, 08:29 PM
It is possible to use the
object
type instead. Now instead of storing the data within the array, the array only stores references to external objects.>>> x=np.full([3], "ABC") >>> x[1] = "Longerstring" >>> x array(['ABC', 'Lon', 'ABC'], dtype='<U3') #note truncation >>> x=np.full([3], "ABC", dtype=object) >>> x[1] = "Longerstring" >>> x array(['ABC', 'Longerstring', 'ABC'], dtype=object)