Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python: numpy.ndarray split

I have array(['USD/EUR', 'nan'], dtype='<U32') that I want to split so that I get [USD, EUR]. How can this be done?

The .split function is not working for me.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you only care about the element 'USD/EUR', then just extract it, then use split(), specifying that the split should be on the '/' character:

import numpy as np

a = np.array(['USD/EUR', 'nan'], dtype='<U32')
b = a[0].split('/')
print(b)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading