I was experimenting with numpy arrays and created a numpy array of strings:
ar1 = np.array(['avinash', 'jay'])
As I have read from from their official guide, operations on numpy array are propagated to individual elements. So I did this:
ar1 * 2
But then I get this error:
TypeError Traceback (most recent call last)
<ipython-input-22-aaac6331c572> in <module>()
----> 1 ar1 * 2
TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and 'int'
But when I used dtype=object
ar1 = np.array(['avinash', 'jay'], dtype=object)
while creating the array I am able to do all operations.
Can anyone tell me why this is happening?