I have a string of numbers like this:
line
Out[2]: '1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0'
I have a numpy array of numbers like this:
rpm
Out[3]:
array([1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0.])
I'd like to add the line of numbers in the string to the numbers in the array, and keep the result in the array.
Is there a simple/elegant way to do this using numpy or python?
np.array(line.split(','),int)also works - givingarraya list of strings and telling it to interpret them as ints.