convert data string from numpy array to int python


convert data string from numpy array to int python



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



Strip 'em and parse 'em:


np.core.defchararray.strip(a, '()').astype(int)





thank you very much, I am a beginner in python
– Santiago molina sanchez
Jun 30 at 1:00





You can replace np.core.defchararray with np.char.
– Abhishek Mishra
Jun 30 at 1:16



np.core.defchararray


np.char





@AbhishekMishra: The NumPy documentation all uses np.core.defchararray, so I do too.
– John Zwinck
Jun 30 at 1:26


np.core.defchararray






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV