I have an np.ndarray:
[[0 4 0 0] [0 5 8 2] [2 7 3 2]]
I want to append in position 0 another element so that the output looks like:
[['cat' 0 4 0 0] ['cat' 0 5 8 2] ['cat' 2 7 3 2]]
I've tried np.insert, append, vstack, and concatenate as indicated in other posts. But, none work. I suspect this is because the type of my array is <class 'numpy.ndarray'>. I've also tried converting it to a list and appending it or to a normal np.array, but nothing seems to work.
Any ideas?
Edit:
I tried:
arr=[np.append('cat',i) for i in my_array]
This works, however, the output looks like:
[array(['cat' 0 4 0 0], dtype=object), array(['cat' 0 5 8 2], dtype=object), array(['cat' 2 7 3 2], dtype=object)]
[['cat'] + i for i in l]