I am trying to add an attribute to a Numpy ndarray using setattr, but I get an error:
import numpy as np
x = np.array([1, 2, 4])
setattr(x, 'new_attr', 1)
AttributeError: numpy.ndarray object has no attribute new_attr
How can I add a new attribute to a Numpy ndarray?