I am new to numpy and I am trying to replace the value in recarray. So I have this array:
import numpy as np
d = [('1', ''),('4', '5'),('7', '8')]
a = np.array(d, dtype=[('first', 'a5'), ('second', 'a5')])
I would like to do something like this:
ind = a=='' #Replace all blanks
a[ind] = '12345'
but it does not work properly. I was able to do this:
col = a['second']
ind = col==''
col[ind] = '54321'
a['second'] = col
Which works, but I would rather do this throughout the entire re-parsing. Does anyone have a better solution?
source
share