2

I have a string Numpy array in Python 3 like this Numpy array,

array[['(155)'],['(255)'],['(165)'],['(147)']]

I need to convert this one to int Numpy array, like this,

array[[115],[255],[165],[147]]

1 Answer 1

2

Strip 'em and parse 'em:

np.core.defchararray.strip(a, '()').astype(int)
Sign up to request clarification or add additional context in comments.

2 Comments

You can replace np.core.defchararray with np.char.
@AbhishekMishra: The NumPy documentation all uses np.core.defchararray, so I do too.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.