How to add an integer to python array?
I am trying to add an integer to an already existing array. But I am getting error “numpy.ndarray' object has no attribute 'append'”:
"AttributeError: 'numpy.ndarray' object has no attribute 'append'"
This is the code I am using:
import numpy as np
data = np.array(f['abc']['efg']['xyz'])
data.append(0)
You have defined a numpy array and trying to append data using a normal python method which is not applicable on numpy arrays. Try using numpy append method:
data = np.append(data, 0)
Hope this will resolve your issue!