I'm starting with:
vals
Out[205]: array([['NA\xa0[1] (16.0\xa0to\xa0N/A)', '12.0\xa0[2]', 'NA\xa0[1]']], dtype=object)
then:
v = vals.astype('str')
v = np.char.replace(v,'\xa0' , ' ')
v
Out[210]:
array([['NA [1] (16.0 to N/A)', '12.0 [2]', 'NA [1]']],
and then:
v = np.char.replace(v,'\s*\[[0-9]+\]\s*' , '').tolist()
v
Out[212]: [['NA [1] (16.0 to N/A)', '12.0 [2]', 'NA [1]']]
The issue is this second replacement doesn't work while the first does. Regex seems to be ok - it should remove such [1]
chars.
I've found later it's something with regex in Python and square brackets: [2]
works [0-9]
doesn't. How to deal with it?